cancel
Showing results for 
Search instead for 
Did you mean: 

Surface automation tutorial - image comparison

alex_ward
Level 2
Hi, I am currently running through the Windows 10 surface automation tutorial 5.0.3 (the one using the BP calculator). However I have become stuck on section 5.1.2 as the behaviour is not as described. In the region editor I have defined a region for the equals button, set retain image to true, and confirmed that the image shows up in the application modeler. However when I try to set a wait stage to check for "Contains Image", it always fails and times out. So instead I used a read stage to grab a copy of the captured region image, exported to PNG, then re-imported into a data object. Then during runtime I re-read the equals key region, and compare the two images. This always fails with the comparison showing false. I have extracted the originally exported PNG and the run-time one and compared them pixel-by-pixel, and they are identical. However I know image comparison is possible, because if I pause after the image read stage and extract the result so both the data items contain the newly extracted run-time image, the decision stage passes as true. So it seems like the read image from region stage is reading a different result each time. I am unable to resolve this. Font smoothing is disabled in windows so that can't be the issue. According to the knowledge base there is a VBO called "Utility - Image Manipulation Other". However, that file does not exist in the VBO folder, only "Utility - Image Manipulation" which does not have "Compare Images In Monochrome". Nor is that VBO available from the website. Has anyone encountered this, and knows how to fix it? Without being able to extract and compare images, I won't really be able to use surface automation.
4 REPLIES 4

Daniel_JebarajJ
Level 3
You can still use the 'Contains Image' property of the Wait stage.. You probably might not have activated the particular application which has the 'equals' button. Try Activating the particular screen and then put this wait stage, checking for the image you're checking with.. Be sure you pass the Retained Image in a local data item in the Wait stage for checking.

alex_ward
Level 2
That has already been done. -The correct application and screen are running and visible -The region is defined and is set to retain image, the image of the region is stored in the Element Snapshot attribute of the element in the Application Explorer- -The image of the element has been extracted from the retained image in the Application Explorer and stored in a data item as an initial value -The data item is referenced by a Wait stage and checks that the element matches true for Contains Image -The wait stage always times out. Has the same behavior for Contains Image and Matches Image

Denis__Dennehy
Level 15
For image comparison I recommend using the actions in the Image Recognition utility object or the Image Search utility object (which is quicker and includes tolerance for robustness) as the recommended best options.

Anonymous
Not applicable
I'm having the same issue. The question I have is, how is the image specified in the inputs to the Contains Image action (see attachment). Thanks.