From 907d1ba6f92ca39de247ce84e8a955b47f814ffe Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Mon, 13 Nov 2023 22:38:13 +1100 Subject: [PATCH] Add a blank prototype which invalidates the odo if matched --- bus_analyzer/bus_analyzer/extract.py | 6 +++++- bus_analyzer/prototypes/odo-digits/blank.png | Bin 0 -> 72 bytes 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 bus_analyzer/prototypes/odo-digits/blank.png diff --git a/bus_analyzer/bus_analyzer/extract.py b/bus_analyzer/bus_analyzer/extract.py index 1660245..971caac 100644 --- a/bus_analyzer/bus_analyzer/extract.py +++ b/bus_analyzer/bus_analyzer/extract.py @@ -164,7 +164,11 @@ def recognize_odometer(prototypes, frame): odo = extract_odo(frame) digits = extract_digits(odo, include_last=False) digits = [recognize_digit(prototypes, digit) for digit in digits] - value = sum(digit * 10.**i for i, (digit, _, _) in enumerate(digits[::-1])) + # If any digit is None, report whole thing as None. Otherwise, calculate the number. + if any(digit is None for digit, _, _ in digits): + value = None + else: + value = sum(digit * 10.**i for i, (digit, _, _) in enumerate(digits[::-1])) # Use average score of digits as frame score score = sum(score for _, score, _ in digits) / len(digits) return value, score, digits diff --git a/bus_analyzer/prototypes/odo-digits/blank.png b/bus_analyzer/prototypes/odo-digits/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..da92561bfb361089663939d76bfec381e54a2b77 GIT binary patch literal 72 zcmeAS@N?(olHy`uVBq!ia0vp^QXtF$Bp7-Wg@u3=zo(01NX4Aw1PRu~2`iWwnD#L+ Tmj8%(3R2?f>gTe~DWM4fw7Cx< literal 0 HcmV?d00001