Find Image by Similarity

Verb: findImage

Available from: <Standard>

Finds an image according to the degree of similarity to the image set in the Image parameter, or the area defined in the Region parameter.

Syntax

findImage --image(Image) [--foregroundwindowonly(Boolean)] --region(Rectangle) --similarity(Numeric) (Boolean)=success (Point)=point

Inputs

Script Designer Required AcceptedTypes Description
--image Image Required Image File with reference image for similarity.
You can select an image from a selection aid or an asset selector.
--foregroundwindowonly Search in foreground window Optional Boolean When this option is enabled, the image is searched only in the foreground window.
--posx X coordinate(Obsolete) Optional Number Horizontal point that represents the beginning of the region to search for in the image.
This parameter is obsolete, use the Region parameter instead.
--posy Y coordinate(Obsolete) Optional Number Vertical point that represents the beginning of the region to search for in the image.
This parameter is obsolete, use the Region parameter instead.
--width Width(Obsolete) Optional Number Width of the region that should be searched for in the image.
This parameter is obsolete, use the Region parameter instead.
--height Height(Obsolete) Optional Number Height of the region that should be searched for in the image.
This parameter is obsolete, use the Region parameter instead.
--region Region Only whenSearch in foreground window is False Rectangle Region where the image should be searched.
--similarity Degree of similarity Required Number Degree of similarity (percentage) indicating how similar the searched image should be to that referenced in the Region parameter.

Outputs

Script Designer AcceptedTypes Description
success Success Boolean Returns "True" if the image was found, or "False" if it was not.
point Point Point Returns the location on the screen where the image was found.

Example

Obtains the image corresponding to the IBM Robotic Process Automation logo on the "Blog - IBM Robotic Process Automation" page, and looks for a matching image on the IBM Robotic Process Automation main page, returning the coordinates of the found image location.

defVar --name imageToCompare --type Image
defVar --name foundImage --type Boolean
defVar --name imageLocation --type Point
webStart --name browser --type "Chrome"
webNavigate --url "https://www.ibm.comblog/"
webGetImage --selector "Id" --id logo imageToCompare=value
webWaitElement --selector "Id" --ide-mail--timeout 00:00:08
webNavigate --url "https://www.ibm.com"
findImage --image ${imageToCompare} --foregroundwindowonly  --similarity 50 foundImage=success imageLocation=point
logMessage --message "Image Location = ${imageLocation}\r\n Image Found = ${foundImage}" --type "Info"
webClose --name browser
//Displays in the IBM Robotic Process Automation Studio console if it was successful in finding the image and what its coordinates are.

See Also

  • Find Pixel
  • Scale Image
  • Wait for Image Change
  • Wait Image