sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #29010
Re: [Question #256327]: Using OCR to click on a on-screen string?
Question #256327 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/256327
Status: Open => Answered
RaiMan proposed the following answer:
Not an official feature yet, but in class
org.sikuli.script.TextRecognizer there is a method listText(ScreenImage,
Region), that returns a list of matches containing the position and
textual content of every word in the given region of the given
screenshot.
I just made a test with it (the first time I think ;-) with this Java
code:
private static void p(String msg, Object... args) {
System.out.println(String.format(msg, args));
}
private static void testListText(Screen s) {
TextRecognizer tr = TextRecognizer.getInstance();
Region reg = s.exists("image").right().highlight(2);
List<Match> words = tr.listText(s.capture(reg), reg);
p("words lenght: %d", words.size());
for (Match m: words) {
if (m.getScore() > 0.8) {
p("%s", m.getText());
m.highlight(1);
}
}
}
getting this output form the NetBeans top button bar:
(Qv
[log] highlight M[1192,55 24x14]@S(S(0)[0,0 1440x900]) S:0.95 C:1204,62 [0/0 msec] for 1.0 secs
<defauIt
[log] highlight M[287,58 52x10]@S(S(0)[0,0 1440x900]) S:0.87 C:313,63 [0/0 msec] for 1.0 secs
conf
[log] highlight M[344,58 27x10]@S(S(0)[0,0 1440x900]) S:0.90 C:357,63 [0/0 msec] for 1.0 secs
Create
[log] highlight M[875,59 38x10]@S(S(0)[0,0 1440x900]) S:0.88 C:894,64 [0/0 msec] for 1.0 secs
Branch
[log] highlight M[920,59 40x10]@S(S(0)[0,0 1440x900]) S:0.88 C:940,64 [0/0 msec] for 1.0 secs
Switch
[log] highlight M[975,59 39x10]@S(S(0)[0,0 1440x900]) S:0.87 C:994,64 [0/0 msec] for 1.0 secs
To
[log] highlight M[1020,59 15x10]@S(S(0)[0,0 1440x900]) S:0.93 C:1027,64 [0/0 msec] for 1.0 secs
Branch
[log] highlight M[1041,59 40x10]@S(S(0)[0,0 1440x900]) S:0.88 C:1061,64 [0/0 msec] for 1.0 secs
Conclusion:
- not so bad ;-)
- the match score seems to signal the probability, that it is text (< 0.8 in this case: no text, misinterpreted symbol, >0,8 most probably text, but one exception: first on ( (Qv ) is a symbol)
Come back if you need help to get it running on the script level.
I am using 1.1.0 of course (but should not make a difference).
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.