← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #705714]: When using captrue() to deposit a local image, and then calling recognition, the score is less than 0.7 most of the time

 

Question #705714 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/705714

    Status: Open => Answered

RaiMan proposed the following answer:
A score less than 0.99 means, that parts of the image pixels are not the same in the match area on screen compared to the given image.
The larger the image is (especially in game scenarios) the higher the risk, that the human thinks, that the image should be found, but at the pixel level there are differences, that lower the score.
So generally it is better to work with smaller images, that are key visuals for the possible situations and then with other small images subsequently decide what exact situation you have on the screen.
An example is how I define the gameArea by an image that is alway visible in the top left corner of the area.

I changed your code a bit, to make it testable for me:

import shutil

# the folder of your running script    
user_file = getBundlePath()
print "BundlePath:", user_file

#Test data
topleft = "topleft.png"
mTopleft = exists(topleft,0)
if (not mTopleft):
    print "game area not there"
    exit()

gameArea = mTopleft.setW(500).setH(1080)
gameArea.highlight(2)

#Stored procedures
imgArea = gameArea.offset(100, 100).setW(300).setH(800)
img_name = "_ETC"
#see comment 
print "saved image:", SCREEN.capture(imgArea).saveInBundle(img_name)

print "Match:", gameArea.find(img_name)

--- running the script prints:

BundlePath: C:\Users\rmhde\iCloudDrive\SikuliX\test.sikuli
[log] highlight M[48,79 500x1080]On(0) S 9998 for 2.0 secs
saved image:  C:\Users\rmhde\iCloudDrive\SikuliX\test.sikuli\_ETC.png
Match: M[148,179 300x800]@S(0) S:1,00 C:298,579 [42 msec]

As you can see: the score is 100%.

--- comment
I am sorry, but at the Python scripting level, the API to store captured images is not up-to-date.
The construct SCREEN.feature() allows you to use functions available on the Java level underneath.
In this case the captured image is stored at the bundle path (hence in the script folder) with the given name as .png being the default ending.
This feature always adds a leading _ (if not already given) which prevents the image from being automatically deleted.
So you just have to define an image name to get the capture stored this way.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.