Fix clipped receipt margins, add time-of-day naming, speed up rotation detection
- vision/document.py: pad_quad() expands the detected quad outward before warping so a straight-line contour fit doesn't clip the first character of every line on a slightly curled/wrinkled receipt - ocr/extract.py + llm/vision.py: extract transaction time (HH:MM) so same-day repeat visits to a vendor get distinct filenames (2023-03-20_1525_walmart.pdf vs. a later same-day trip) - vision/orient.py: downscale before Tesseract OSD/confidence-sweep rotation detection — this was the dominant cost in the detection phase (7x speedup: 472s -> 67s on a 36s test video)
This commit is contained in:
@@ -46,6 +46,27 @@ def test_build_name_nothing_found():
|
||||
assert result.source == "none"
|
||||
|
||||
|
||||
def test_build_name_with_time_disambiguates_same_day_visits():
|
||||
dt = datetime(2026, 1, 1, 12, 0, 0)
|
||||
morning = build_name("2023-03-20", "WALMART", dt, time="09:05")
|
||||
evening = build_name("2023-03-20", "WALMART", dt, time="18:42")
|
||||
assert morning.stem == "2023-03-20_0905_walmart"
|
||||
assert evening.stem == "2023-03-20_1842_walmart"
|
||||
assert morning.stem != evening.stem
|
||||
|
||||
|
||||
def test_build_name_invalid_time_ignored():
|
||||
dt = datetime(2026, 1, 1, 12, 0, 0)
|
||||
result = build_name("2023-03-14", "METRO", dt, time="not-a-time")
|
||||
assert result.stem == "2023-03-14_metro"
|
||||
|
||||
|
||||
def test_build_name_time_without_date_ignored():
|
||||
dt = datetime(2026, 1, 1, 12, 0, 0)
|
||||
result = build_name(None, "METRO", dt, time="09:05")
|
||||
assert result.stem == "UNSORTED_metro_20260101_120000"
|
||||
|
||||
|
||||
def test_build_name_tax_form_with_year_and_org():
|
||||
dt = datetime(2026, 1, 1, 12, 0, 0)
|
||||
result = build_name(
|
||||
|
||||
Reference in New Issue
Block a user