← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #240729]: Infinite loop when detecting spaces

 

Question #240729 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/240729

    Status: Open => Answered

RaiMan proposed the following answer:
I just made a test with this simple script:

Settings.MoveMouseDelay=0
img = "1386938448955.png" # headline of this question: Infinite loop when detecting spaces
m = find(img)
highlight(-1)
nxt = m.left(1).right(1)
gap = capture(nxt)
start = time.time()
n = 0
for i in range(m.w):
    nxt = nxt.right(1)
    if nxt.exists(Pattern(gap).similar(0.99), 0):
        nxt.hover()
        n += 1
total = time.time() - start
print m.w, total/m.w, n, total, total/n

result with version 1.0.1:
493 0.264811359119 113 130.552000046 1.15532743403

result with the current development version of 1.1 (soon as Beta1):
493 0.0113164300125 122 5.57899999619 0.0457295081655

This is the first time I found an example, where the optimizations in
1.1 are such impressive: only 6 seconds versus 130 seconds in 1.0.1 ---
woooow about 20 times faster ;-)

So I think, you might develop your approach and make it working accurately and robustly.
The wanted speed will come with 1.1 ;-)

*** Regarding the other algorithm you have proposed.. I think it is
similar to the one I have explained in my question. Or did I miss
something? :)

I think not really:
suggested, you have isolated the characters, then with your version, you have to compare each character with the captured symbols (which are about 70 +/-). You might arrange them according to their frequency in your texts, but in average their will be around 20+ compares per character (20 searches in very small images)
If you take my approach, then it is one search in an image containing all characters in defined places (which might be a bit faster on average).

BTW: you can optimise your approach by checking for each character,
wether it is uppercase or lowercase (check the top part of the space on
empty) and wether it is a character having a decender (checking the
bottom space on empty). This might reduce the average character
recognition, since you only search in a specific group of characters.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.