Image Recognition returns only the first image found.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
CharlieMSU
Newbie
Posts: 1
Joined: Mon Dec 10, 2018 7:08 pm

Image Recognition returns only the first image found.

Post by CharlieMSU » Mon Dec 10, 2018 7:35 pm

Gents,
Hope you can help. I downloaded the latest Macro Scheduler with hopes it would open a whole new world to my scripting needs, the "image recognition" feature that is. Not knowing where to start, I browsed this forum and came across a script by Marcus that allows me to use an array to capture the coordinates of every image found on the screen. Everything looks good, but it turns out the script ONLY RETURNS THE FIRST IMAGE FOUND. I must point out that all instances of the image are identical to each other. I have tried lowering the coefficient all the way to 0.1 and the script still can only identify one instance of the image. I'm pasting the script below for your reference. I'm also attaching a png file of a screenshot of all the images I've tried to capture. As you can see, these are pretty simple images.

Please advise on what I must do to get this amazing tool to work for me. Thanks in advance!

Charlie

---------

//Find and Left Click Bottom Left of
FindImagePos>%BMP_DIR%\image_10.bmp,SCREEN,0.7,3,XPosE,YPosE,NumFoundEffect,CCOEFF

MessageModal>NumFoundCause

If>NumFoundCause>0
Let>k=0
Repeat>k
MouseMove>XPosC_%k%,YPosC_%k%
Wait>2.5

Let>XPosC1_%k%=XPosC_%k%
Add>XPosC1_%k%,80
Let>YPosC1_%k%=YPosC_%k%
Add>YPosC1_%k%,20

Let>relayAddress=
Let>strSpace=
ConCat>relayAddress,strSpace

OCRArea>XPosC_%k%,YPosC_%k%,XPosC1_%k%,YPosC1_%k%,relayAdd
ConCat>relayAddress,relayAdd
ConCat>relayAddress,

Let>relayType=O
ConCat>relayType,

Let>WLN_NOCRLF=1
WriteLn>filePath,nWLNRes,relayAddress
WriteLn>filePath,nWLNRes,relayType

Wait>0.5
Let>k=k+1

Until>k=NumFoundCause
EndIf

-------

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Image Recognition returns only the first image found.

Post by Marcus Tettmar » Tue Dec 11, 2018 9:45 am

As per the docs CCOEFF matching method only returns one match - the most statistically likely candidate.

But EXACT will return multiple exact matches if there are any. So for multiple identical matches use EXACT.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts