Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
fix(single-mode): error while recognizing race menu
Browse files Browse the repository at this point in the history
fix #358
  • Loading branch information
NateScarlet committed Aug 28, 2022
1 parent a9b7076 commit 80f64bf
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
70 changes: 70 additions & 0 deletions auto_derby/data/ocr_labels.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1114,3 +1114,73 @@ fe7f7ffe3ffc33e477e6ffffffffc7e183e183e0c3e1e3e7e367037c03700020,岡
00001c00fe7ffc7ffc5dfe3cfe3c7c3c7c3cfe4cc74dc7fdce7dc61dce0dfe08,都
18003e043e263e627e63fec3ff41ff00ff7fdf7f027f026703630367337f207f,船
00000c3f0c1e3e1ffeffdefffcfffe633e001f000f7f8cc18cc080ff80ff80f0,橋
007ec0fff01ffc07fe01fe00ff00ff00ff00ff00fe00fe01fc07f01fc03f003c,(
8001e003fefffc7f0000fc3ffc3f1c381c38fc3ff80380118c31def1e7e1e001,京
c238f678fe7ffeffcee3c6e386e186c186c186c186c186c187e1c7e1c7e18000,m
4010e038fe7fdeffcee38ee38ee38ec38ec38ec38ec38ec38ec386e187e18000,m
18183c3cffffff7f00008000fc3fff7f00780038001cdc07fe01ff01e3ffc2ff,芝
80018001c003fe7ffeffc6f382e182e182e1c6e7ffffffffc3e3800180018001,中
1f7f930383039703bf3f9e3f9c3398239833b93f993f89038d039f039f7f1f7f,距
100038007ffcfffebfff9f67ff67feff1c7e1c641e6c0ffc0e6cdf64fffc407c,離
4000e030ff79dff78fe38fe387e387e387e387e387e387e387e387e386e10040,m
e338ff7fcf73cf6387e387e387e387e387e387e387e387e387e387e387e183c1,m
3c3cffffffff38180000c003ff3ffe3f0038001c0c0ffc07fe01ff01e3ff00c0,芝
ffffff7f007c0038003c003c001e380ff807f807f003e003c003800780070007,マ
04ff0eff3e003e001eff1e7f1e633f673f7f3e761c621c623e622676027f007f,短
3e7f3f7f730373033f0f3e7f187f18633863387f180718031e033f7f0f7f0001,距
e423ffffff7f00000000fc3f1c381c38fc3fd83780038833de73cfe1e041c000,京
0038003c003e003e003e003c0038003000300030003000300030007000700030,1
10007e487f7c3ffebf7fbf67ff7ffeff18661c667e7e0f7e0f66df66c3fe007c,離
fc3f3f3f0e3c003c003c003ec01fe01f003f00fc00fc00fc06fcff7ffe3ff80f,3
000006ff1e003e003f001fff1fe3bfe37fff3c761c621c623e66677607ff82ff,短
0000fee074e0e0f0e0f0e2e0e6f0e07fe003e07fe6ff7efc7ef067f067796078,潟
081c0c3e3c3e3f3eff73ff73ffff7ff07f607f67ff67ff67bf6f837f037f0030,崎
1e7e3fffe303e303f7033e7f1c7f18633963397f197f19031b033f7f3fff0003,距
000038243c6c3cfe9d7fdf6fff7fffff086e1864fe7cdf7c8f6cff7cff7c0004,離
3c7e3e7f370337031f031fff1fff17672767e77bff79ff79c779c77fc3440200,阪
3e7fbe7fb603b203b603be7fbc7fb873b873b07fb03f98039803be7fbeff0001,距
000038447c6c787ef87fd82fee7ffe7f1c7e186efe7ecf7ec92eff7eff7e0004,離
0000fc1ffe1ffc1ff81e001e001f001f001f000f000f000fffffffffffffffff,ュ
fc1ffc3ffcfffc9f0000fe7fffffff7fc003c003e001e001f000780078003800,デ
38c0f8d0f811f00100000f001fe03ef03c7c007e003fc01ff007f801fc007800,ジ
300c781cffff03ff00407c60fe64ceecfeecfeec4eecfee4e6e0e678e67c4410,前
100c381effffffff00000000fe04ff44ff44ff44e744ff40ff60e770e7786638,前
f83ffc7f1ef800f000f00078c03fc01f003e00f800e000e002e00ff0fffffc3f,3
e00f7c3c3c381e701ef01ff01ff01ff01ff01ff01ef01ef87e7cfc3ff81f8003,0
7e7e76e666e666e666e666e60efc02e0c2e7e2e762e6f2e762ee22ee22f60262,開
fc7ffc7ff81f00000340ffffffff00f000f000780038003e001fc00fc007c001,ラ
847fc67f626f1f031c431cc30cc33ec3fec3fee31c7fbc3bfe3bde7f9e4e0000,級
380c781effff0000fc00fe60ce65ce67ee67fe67ce67ee67fe60c660c678c438,前
08039c33cc3bc61f004f7847fc7fcee78f43ee7fee79cc390c3f8c3fec7b0c00,後
fc3ffc7ffc7f0000000003c0ffffffff00f80078003c003e801fc00fe003c000,ラ
fc1ffc1f041f000e000f000f80078003c007e00ff01ff83f7e3c3f781ff80ff0,ス
f003fe1f0f3c0738077807f807f80ffcfefff8f300e0007000380f3cfe1ff807,9
847fc67ff66f1f461ec61cc62cc66ec7fec7fe470c7e8479ce7fceff9cec0800,級
0420fc3ffc3ffc1ff007ffffff7ffe7f0078003c003e001f800fe007e003c000,ラ
fc1ffc7ffcff009000000000ffffffffffff8007c003c001e001f00078007800,デ
0f000f300f300f7eff7fff1fff031f000f000f000f000f000f00ff7ffefffc7f,ビ
0000867fa37f33231f630e6334767e66ff67fe6f8c7dce39cc79cc7d8c440800,級
0280ffffffff00f000f00078603cf03ef01ff00df00078003c003c003c001c00,ア
84018c318c399c198011c003ff3ffe3ffc3bfe7fffffffffc003800180018001,半
847fc27fe33f0f230e630ce32ce33ee3ffe3fe670c3f9c31de7bdeff8eee0c00,級
f81ffc1ffc1ff81f001e001c001c001c001c001c001c001c001effffffffffff,ュ
480cecccceffc67fc719c77fc77fff18fe38fe18e618c63cc618c63cc6ffc400,催
0c7f867f732736271c673cf77ce77fc7ffcf1c6f187bf839997999ef18001800,級
0c038e31c631821f800788e7fcffcec7cf43cf63fe3ffe318c3f041feeff6440,後
0000000000000000000000000000000000000000800fe01fe01fe01f801f801f,","
ffffffff02f000f000f0c078e03de03ff01ef01cf000f800780038003c001c00,ア
c001e001e001e001e001e003f007ffffffffffffffffe003e003e001e001e001,+
2003e003e003e003e003ff3fff7ff49ff00ff007e003e003e003e003e003c001,+
ff1fff1fff0f0f0007008703ff1f1f3f067c00f800f800f8077cff3ffe1fe001,5
0c003f18331c330c330633073f039f018e39c07c60ee60ee30ee18ee187c0c7c,%
f00f7c3e1e381e381e387e3efc3ffc3f3e7c0ff80ff01ff83ffcfe7ff81f8001,8
fc01fe3ffe001e001e003e00fe1ffe3f0e7c007000f000f81e7cfe7ffe3ff80f,5
f01ffc3ffe3f1e7c0078007c003ec01ff007f8017c003e00fe7fffffff7f0200,2
1e183f18310c3106310633039f038e79c078c0fc60ec20ee30ee18ee08fc0078,%
0e003f08330c730c73067707be0380018001c07c60ec60cc30cc30ec187c0038,%
0001f03f7cf83cf01ce01cf07878f83ff87f7cf81cf01ee01ee01cf07cf8f83f,8
fc3ffe3ffe1f1e001e001e00ff3ffe7f3c7c00f800f000f00cf03cfc7c3ef81f,5
f81ff83e1c780c701c783838f81ff81ffc3f1e700fe00fe01ff01e78fc3ff81f,8
3f183f18331c730c730637033f039e31c078c0fc60cc20ce30cc18cc187c0030,%
3e303e386718670c670c77067e03be038879c0fdc0dc60cc60cc30cc18fc18f8,%
c003f81f3c3e1e780e780678077807f807f8077806780e781e787e3efc1ff003,0
5 changes: 5 additions & 0 deletions auto_derby/imagetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ def auto_crop(cv_img: np.ndarray) -> np.ndarray:
return cv_img[t:b, l:r]


def auto_crop_pil(pil_img: Image) -> Image:
bbox = pil_img.getbbox()
return pil_img.crop(bbox)


def data_url(img: Image) -> Text:
b = io.BytesIO()
img.save(b, "PNG")
Expand Down
4 changes: 4 additions & 0 deletions auto_derby/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ def text(img: Image, *, threshold: float = 0.8) -> Text:
reload_on_demand()
ret = ""

img = imagetools.auto_crop_pil(img)
w, h = img.width, img.height
if h * w == 0:
app.log.text("ocr result is empty", level=app.DEBUG)
return ""

if img.height < _LINE_HEIGHT:
w = round(_LINE_HEIGHT / h * w)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
[
"Course<川崎 dart 2100m 左>",
[
406,
1200
]
],
[
"Course<阪神 turf 2000m 右·内>",
[
406,
1430
]
]
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80f64bf

Please sign in to comment.