From 64f5873b3b5e21185ad7b4dd2eac3e7b676d134a Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Sun, 10 Nov 2024 17:41:16 -0800 Subject: [PATCH] Bug fixed --- bus_analyzer/bus_analyzer/extract.py | 6 ++++-- bus_analyzer/bus_analyzer/main.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bus_analyzer/bus_analyzer/extract.py b/bus_analyzer/bus_analyzer/extract.py index cb5a20f..7512a86 100644 --- a/bus_analyzer/bus_analyzer/extract.py +++ b/bus_analyzer/bus_analyzer/extract.py @@ -201,7 +201,8 @@ def recognize_odometer(prototypes, frame): """ odo = frame.crop(AREA_COORDS["odo"]) digits = extract_digits(odo, "odo") - mask = Image.open(prototypes['mask'][0]) + mask = prototypes['mask']['mask'] + mask = mask.convert(mode='L') digits = [ recognize_digit(prototypes["odo-digits"], digit, mask=mask) for digit in digits[:-1] ] + [ @@ -220,7 +221,8 @@ def recognize_odometer(prototypes, frame): def recognize_clock(prototypes, frame): clock = frame.crop(AREA_COORDS["clock"]) digits = extract_digits(clock, "clock") - mask = Image.open(prototypes['mask'][0]) + mask = prototypes['mask']['mask'] + mask = mask.convert(mode='L') digits = [ recognize_digit(prototypes["odo-digits"], digit, i == 0, mask=mask) for i, digit in enumerate(digits) ] diff --git a/bus_analyzer/bus_analyzer/main.py b/bus_analyzer/bus_analyzer/main.py index 0fd1c86..a53ef86 100644 --- a/bus_analyzer/bus_analyzer/main.py +++ b/bus_analyzer/bus_analyzer/main.py @@ -105,7 +105,7 @@ def do_analyze_segment(dbconnect, *segment_paths, base_dir='.', prototypes_path= dbmanager = database.DBManager(dsn=dbconnect) for segment_path in segment_paths: - analyze_segment(db_manager, prototypes, segment_path) + analyze_segment(dbmanager, prototypes, segment_path) def analyze_segment(db_manager, prototypes, segment_path, check_segment_name=None):