Sikuli won't find previously captured image

Asked by Miguel E Torrealba

Hi, totally new to Sikuli and programming, great program!

I am having trouble making sikuli recognize an image in one region of the screen and then find it in another region of the screen. Everything works great with the regions but it just doesn't like captured images.

if exists("1493406248051.png"):
    waitVanish("1493406248051.png",180)

if exists("1493405892790.png"):
    waitVanish("1493405892790.png",180)
    wait(Pattern("1493406514054.png").similar(0.80),200)

import shutil
import os

folder = "C:\SikuliX\RESUMEN"
img = capture(Region(183,75,35,36))
shutil.move(img, os.path.join(folder, "FORMA.png"))

wait(2)
reg2 = Region(Region(257,37,331,118))
reg2.click("C:\SikuliX\RESUMEN\FORMA.png")

exit()

I am absolutely sure the regions are right, and I checked the image captured by opening it on my hard drive and it's great. But it won't find FORMA.png

So to rule out a region problem I widened the search:
click("C:\SikuliX\RESUMEN\FORMA.png")

Which I suppose searches for it on the whole screen, but still doesn't even find the image on the same region it was captured.

Help please, thanks

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

folder = "C:\SikuliX\RESUMEN"

must be either
folder = "C:\\SikuliX\\RESUMEN" # escaped backslash

or
folder = r"C:\SikuliX\RESUMEN" # raw string

BTW: with version 1.1.1 in the IDE, you can name captured pictures at capture time:

Instead of something like this:
folder = "C:\SikuliX\RESUMEN"
img = capture(Region(183,75,35,36))
shutil.move(img, os.path.join(folder, "FORMA.png"))

you can simply do that:
in a line having
forma =

leave the cursor after the = and click the capture button.
after the capture, the image will be named forma.png and could be used either as
reg2.click("forma.png") or even reg2.click("forma")

or using the variable
reg2.click(forma)

this feature from the beginning encourages a naming convention

Can you help with this problem?

Provide an answer of your own, or ask Miguel E Torrealba for more information if necessary.

To post a message you must log in.