Image search out of the region

Asked by andrea on 2012-03-15

Hi, I created a region on my screen and try to find a blu rectangle.
Because I got error " BTS.png image is not found" I use the matching preview function on sikuli IDE to see what the code find.
I have highlighted blu rectangle outside my defined region.
What is wrong on my code?

region=(some picture)
 centro=region.getCenter()
 mouseMove(centro)
 wait(1)
 region.rightClick("BTS.png")

It is because the matching preview functionon sikuli IDE doesn't know about the region I defined?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2012-03-18
Last query:
2012-03-18
Last reply:
2012-03-17
RaiMan (raimund-hocke) said : #1

--- region=(some picture)
did you capture the region in the IDE and "some picture" is the thumbnail?
otherwise this does not make sense.

--- centro=region.getCenter(); mouseMove(centro); wait(1)
this is not needed, because rightClick() would move the mouse to the center of the match and click.

The blue rectangle might be a problem, because Sikuli has some problems with solid colored areas.

Send me a screenshot or put it somewhere in the net and post a link.

This is how it should work (at least with the latest build r931):

reg = Region(x, y, w, h) # captured or somehow evaluated
reg.rightClick("image.png")

andrea (andrea-merli69) said : #2

Hi RaiMan,
I am using the latest build. The reason I am trying to use a blue rectangle is because the white text, with blue background change dynamically and I cannot copy from screen. So I need to find a way that is independent from the text. Because in the region created there is only one object highlight with blue background I think could work.
Here the link to blue rectangle used and 2 possible object I need to match. (if you don't see please let me know where I can send snapshot.

https://plus.google.com/u/0/116251563727288108300/posts/YBWUwnFLjab

Of course any suggestion to get a better result is welcome.
I notice that results change base on the dimension of the blue rectangle. Too big does not match. Is there a reason?

Thanks
Andrea

Best RaiMan (raimund-hocke) said : #3

With your Google+ page
https://plus.google.com/u/0/116251563727288108300/posts

If there is only one object with blue background, then you have to use a solid blue rectangle, that can be found.
With an image editor I reduced the blue search image to dimension 14x4 and with the region restricted to the above images, I had no problem.

the relevant script part:
# page open in browser
imgBlue = "blue-1.png"
imgTop = "UbermichBeit.png"
top = find(imgTop)
top.highlight(1)
reg = top.below(100)
reg.highlight(1) # contains the images
mBlue = reg.find(imgBlue)
mBlue.highlight(1)
reg.highlight(1)
for m in reg.findAll(imgBlue):
    m.highlight(1)

the single find() matches in the solid blue rectangle.

The findAll() returns many matches, that have to be somehow filtered. But in your case, the best match (first) might be sufficient already.

andrea (andrea-merli69) said : #4

I RaiMan thank you for your help.

Andrea