sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #53874
Re: [Question #687508]: Using OCR to select day of the month
Question #687508 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/687508
RaiMan proposed the following answer:
I made some tests with your given calendar image.
I have to admit, that it seems, that the SikuliX internal optimisation
of the images before doing the OCR still has to be improved further.
This is my test script, that you have to either test in the SikuliX IDE or transcript it to Java code.
Your calendar image is visible on the screen.
lnn = 5 # select a week
OCR = TextOCR.start()
reg = Region(163,89,228,198) # the calendar region
lines = 8 # number of lines in the grid
cols = 7 # number of columns
lh = reg.h/lines # line height calculated
cw = reg.w/cols # column width calculated
line0 = reg.above().below(lh)
#line0.highlight(1)
uprint(line0.text()) # prints December | 2019
# step through the weeks and days
for ln in range(lnn + 1, lnn + 2):
line = Region(reg.x, reg.y + ln * lh + ln, reg.w, lh - 5)
line.highlight(1)
for cn in range(7):
day = Region(line.x + cn * cw + cn + 2, line.y, cw - 5, line.h)
#day.highlight(1)
print OCR.doOCR(Image.create(capture(day)).resize(2)).strip()
--- comments
- the final line and day regions are adjusted in position and dimension, to cut out the grid frames
- the key point is to work with an image, that is resized with factor 2 (the simple method doOCR() with the standard optimisation does not deliver good results)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.