Image recognition fail

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
ammone95
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 9:43 pm

Image recognition fail

Post by ammone95 » Thu Mar 02, 2017 8:40 pm

Hi, the other day I was writing a code for a mobile game to automate some processes, I mirror the phone screen trough the Mobizen application and using a WaitScreenImage and a FindImagePos to find the specific button to press.
The first time it worked fine, but when I returned the day after the program has not recognized any of the images, forcing me to redo the screen for each button ... Is there a way to solve it? I can instead use another code to recognize the inscription inside of the buttons (such as START BATTLE, OK or SELL) and find their location?
Thanks

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Image recognition fail

Post by Dorian (MJT support) » Fri Mar 03, 2017 1:29 am

I think the first question to ask is whether you're using Correlation Coefficient, or Exact Match?

I would try Correlation Coefficient and then experiment with the Tolerance setting.

I've attached a screenshot of the Image Recognition Wizard in case it helps.
Yes, we have a Custom Scripting Service. Message me or go here

ammone95
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 9:43 pm

Re: Image recognition fail

Post by ammone95 » Fri Mar 03, 2017 8:34 pm

Yes, i'm using the Correlation Coefficient. Otherwise the program can't detect any of the images... I've tried raising up the tolerance step by step until i reached 10 and nothing

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Image recognition fail

Post by Dorian (MJT support) » Fri Mar 03, 2017 8:58 pm

A tolerance of 1 is looking for an exact match. If you mean to make it 100% pixel to pixel precise then use EXACT.

Try lowering the tolerance. If it wasn't matching at 0.7, try 0.6, and so on.
Yes, we have a Custom Scripting Service. Message me or go here

ammone95
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 9:43 pm

Re: Image recognition fail

Post by ammone95 » Sat Mar 04, 2017 10:35 am

This is the code i use, the number 0.7 is the color tolerance and i've found that raising it, the program can find the image more easily. I've tried to lower it down until 0.1 but nothing happens

Code: Select all

SetFocus>Mobizen Mirroring
WaitScreenImage>C:\Users\Desktop\MacroTest\start.bmp,0.7
FindImagePos>C:\Users\Desktop\MacroTest\start.bmp,SCREEN,0.7,0,XArr,YArr,start
if>start>0
    MouseMove>XArr_0,YArr_0
    LClick
endif
I'm using the MacroScheduler 11 and i don't have the admin permission to upgrade it

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1386
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Image recognition fail

Post by Dorian (MJT support) » Mon Mar 06, 2017 9:17 pm

This is a little puzzling, as CCOEFF wasn't in v11 so I can't imagine tweaking that tolerance will make any difference at all.

It was introduced in v14. There have been some major Image Recognition improvements since v11.

Version 14.0.2 31/01/2013
- Script Additions/Improvements:
- New portable/tolerant image recognition engine using Coefficient Correlation Template Matching

Version 14.0.13 30/07/2013
- Further code improvements in CCOEFF image recognition engine

Source : Macro Scheduler version history page.
Yes, we have a Custom Scripting Service. Message me or go here

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

Re: Image recognition fail

Post by Marcus Tettmar » Wed Mar 08, 2017 9:03 am

ammone95 wrote:This is the code i use, the number 0.7 is the color tolerance and i've found that raising it, the program can find the image more easily. I've tried to lower it down until 0.1 but nothing happens

Code: Select all

SetFocus>Mobizen Mirroring
WaitScreenImage>C:\Users\Desktop\MacroTest\start.bmp,0.7
FindImagePos>C:\Users\Desktop\MacroTest\start.bmp,SCREEN,0.7,0,XArr,YArr,start
if>start>0
    MouseMove>XArr_0,YArr_0
    LClick
endif
I'm using the MacroScheduler 11 and i don't have the admin permission to upgrade it
This is not CCOEFF if you are using v11. If must be EXACT. For EXACT the color tolerence works differently and needs to be HIGHER to be more tolerant because it refers to a color variance. Therefore it needs to be a number between 0 and 255. Whole numbers only. Not sure what 0.7 would do. But that's pretty INTOLERANT.

From the manual:
EXACT: For exact matching tolerance specifies the color tolerance. If tolerance is zero the pixel colors must match exactly. Tolerance can be set to a value between 0 and 255. If larger than zero the red, green and blue values of the pixels in bitmap_to_scan are checked to see if they are within the tolerance specified (color value + or - tolerance). Smaller values match less and larger values match more. EXACT matching may return more than 1 match if there are more than 1 exact matches in the target area. EXACT can only work with bitmap files.
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
cron
Sign up to our newsletter for free automation tips, tricks & discounts