优化课表识别并支持重新识别
This commit is contained in:
@@ -61,6 +61,17 @@ class TimetableOccupancyTests(unittest.TestCase):
|
||||
result=ocr.occupancy_from_blocks(mistaken,blocks,(680,600))
|
||||
self.assertEqual(result['cells'],normal['cells'])
|
||||
|
||||
def test_grid_handles_month_label_merged_into_monday_header(self):
|
||||
raw=sample_image()
|
||||
complete=ocr.occupancy_from_grid(headers(),raw,(680,600))
|
||||
compact = [line(55,100,'11月16一')] + [
|
||||
line(200+80*i,100,f'{17+i}{weekday}') for i,weekday in enumerate('二三四五六日')
|
||||
] + [line(35,160+40*i,str(i+1)) for i in range(10)]
|
||||
result=ocr.occupancy_from_grid(compact,raw,(680,600))
|
||||
self.assertIsNotNone(result)
|
||||
self.assertEqual(result['method'],'color_grid')
|
||||
self.assertEqual(result['cells'],complete['cells'])
|
||||
|
||||
def test_layout_extraction_still_runs_when_monday_and_morning_are_empty(self):
|
||||
image=Image.new('RGB',(680,900),'white');draw=ImageDraw.Draw(image)
|
||||
draw.rectangle((325,500,395,650),fill='#8ba3fc')
|
||||
@@ -73,7 +84,7 @@ class TimetableOccupancyTests(unittest.TestCase):
|
||||
raw=sample_image()
|
||||
with patch.object(ocr,'layout_lines',return_value=headers()) as layout,patch.object(ocr,'read_image') as full_ocr:
|
||||
first=ocr.recognize(raw)
|
||||
self.assertEqual(first['method'],'color_blocks');self.assertFalse(first['cache_hit'])
|
||||
self.assertEqual(first['method'],'color_grid');self.assertFalse(first['cache_hit'])
|
||||
self.assertEqual(first['raw_text'],'');self.assertTrue(all(c['courses']=='' for c in first['cells']))
|
||||
first['cells'][0]['status']='changed'
|
||||
second=ocr.recognize(raw)
|
||||
|
||||
Reference in New Issue
Block a user