Compare commits

..

No commits in common. 'aebbb603fcd12c5ce530218096775d1caa92d5db' and '941050aea9c674ef09253f4e43b7b212144dbfcb' have entirely different histories.

@ -344,10 +344,10 @@ def recognize_time_of_day(frame):
return best, distance
def extract_segment(prototypes, segment, time):
def extract_segment(prototypes, segment):
ODO_SCORE_THRESHOLD = 0.01
CLOCK_SCORE_THRESHOLD = 0.01
frame_data = b"".join(extract_frame([segment], time))
frame_data = b"".join(extract_frame([segment], segment.start))
frame = Image.open(BytesIO(frame_data))
odometer, score, _ = recognize_odometer(prototypes, frame)
if score < ODO_SCORE_THRESHOLD:

@ -26,7 +26,7 @@ def do_extract_segment(*segment_paths, prototypes_path="./prototypes"):
prototypes = load_prototypes(prototypes_path)
for segment_path in segment_paths:
segment_info = parse_segment_path(segment_path)
odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.start)
odometer, clock, tod = extract_segment(prototypes, segment_info)
print(f"{segment_path} {odometer} {clock} {tod}")
@ -76,7 +76,7 @@ def compare_segments(dbconnect, base_dir='.', prototypes_path="./prototypes", si
for old_odometer, (segment, old_clock, old_tod) in selected:
path = os.path.join(base_dir, segment)
segment_info = parse_segment_path(path)
odometer, clock, tod = extract_segment(prototypes, segment_info, segment_info.start)
odometer, clock, tod = extract_segment(prototypes, segment_info)
results.append((segment, {
"odo": (old_odometer, odometer),
"clock": (old_clock, clock),
@ -118,13 +118,8 @@ def analyze_segment(db_manager, prototypes, segment_path, check_segment_name=Non
if check_segment_name is not None:
assert segment_name == check_segment_name
# A timestamp fully at the end doesn't get us a valid frame.
# But we want to be as late as possible to minimize latency.
# We attempt to do a fixed time before the end, or use the start if too short.
timestamp = max(segment_info.start, segment_info.end - datetime.timedelta(seconds=0.1))
try:
odometer, clock, tod = extract_segment(prototypes, segment_info, timestamp)
odometer, clock, tod = extract_segment(prototypes, segment_info)
except Exception:
logging.warning(f"Failed to extract segment {segment_path!r}", exc_info=True)
odometer = None
@ -148,7 +143,7 @@ def analyze_segment(db_manager, prototypes, segment_path, check_segment_name=Non
timeofday = %(timeofday)s
""",
channel=segment_info.channel,
timestamp=timestamp,
timestamp=segment_info.start,
segment=segment_name,
error=error,
odometer=odometer,
@ -205,7 +200,7 @@ def main(
prototypes_path="./prototypes",
concurrency=10,
):
CHECK_INTERVAL = 0.5
CHECK_INTERVAL = 2
stopping = gevent.event.Event()

Loading…
Cancel
Save