Image Recognition Help

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Image Recognition Help

Post by aks » Mon Nov 03, 2008 11:25 am

Hi,

If i have to achive an end to end automation using only image recognition feature then how do i script the following scenerio:

There is a checkbox on one of the window opened inside a remote desktop screen. The image of this chekbox and its message is my reference image. Now screenCapture will capture the entire desktop, i want to capture only checkbox section in the whole screen and compare if it is matches with the reference image. Is this possible? Can i get the coordinates of only checkbox image somehow? Does FindImagePos command returns the coordinates of the image to be found on the screen? This section is not very clear in the help document.

Regards,
Aks

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

Post by Marcus Tettmar » Mon Nov 03, 2008 12:03 pm

FindImagePos returns EITHER the upper left coordinate of a match, or the center position of a match, depending on what the value of the CENTER parameter is.

FindImagePos will return the number of matches found and all X,Y coordinates of each match are returned in the specified X, Y arrays.

Have you seen the following tutorial and video:
http://www.mjtnet.com/blog/2007/02/20/h ... cognition/
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Tue Nov 04, 2008 8:44 am

Hi Marcus,

yes i refered the demo as well as blog on image recognition. Using the same approch given in the blog a smaller image is found in the screen image using FindImagePos. Now as you explained FindImagePos will return the cordinates of the smaller image. Using these cordinates can i recapture only that smaller image for validation?

Thanks & Regards,
Aks

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

Post by Marcus Tettmar » Tue Nov 04, 2008 9:04 am

Yes, if you set FindImagePos to return the top left position, and you know the dimensions of the image you are seeking (you made it) you can then simply use ScreenCapture passing the upper left position as returned by FindImagePos and adding the dimensions to that position to determine the lower right bounds.

E.g., if your needle was 10x10 pixels:

Code: Select all

FindImagePos>needle,SCREEN,0,0,Xs,Ys,n
If>n>0
  //for this example just get first match
  Let>x1=Xs_0
  Let>y1=Xs_0
  Let>x2=x1+10
  Let>y2=y1+10
  ScreenCapture>x1,y1,x2,y2,c:\newbmp.bmp
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Tue Nov 04, 2008 10:03 am

Wow that is very very usefull. I will try this and get back to you.

Thank you
Aks

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Wed Nov 05, 2008 10:50 am

I tried doing that but i guess i am going wrong in specifying the dimension of the image. Needle image dimensions is 32x29
FindImagePos>needle,SCREEN,0,0,Xs,Ys,n
If>n>0
//for this example just get first match
Let>x1=Xs_0
Let>y1=Xs_0
Let>x2=x1+32
Let>y2=y1+29
ScreenCapture>x1,y1,x2,y2,c:\newbmp.bmp
Endif

But this does not capture the exact image. I am trying to find a menu inside a wordpad opened inside a remote desktop window.

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

Post by Marcus Tettmar » Wed Nov 05, 2008 10:55 am

Both x1 and y1 have been set to Xs_0. 5th line should be:

Let>y1=Ys_0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Wed Nov 05, 2008 1:45 pm

Ooops my mistake. Thanks so much. I have one more question.
Does Macro Scheduler support OCR? If FindImagePos returns more than one match how will i perform some operation on a specific image?

Thanks & Regards,
Aks

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

Post by Marcus Tettmar » Wed Nov 05, 2008 3:05 pm

Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

aks
Newbie
Posts: 18
Joined: Wed Oct 15, 2008 8:54 am

Post by aks » Thu Nov 06, 2008 10:16 am

:D That's really neat!!!. Ok now i have to run one of the macro script form commandline on winxp. I used this command 'msched myscript'.
But system is not recognizing 'msched' as a valid command. Is there any setting changes i have to do?

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

Post by Marcus Tettmar » Thu Nov 06, 2008 10:19 am

Well I doubt Macro Scheduler is in your path so you probably need to specify the full path to Macro Scheduler:

"c:\program files\macro scheduler\msched.exe" mymacro

Change the path to suit your system.

Also, if you installed Macro Scheduler with the defaults then .scp files will be associated with Macro Scheduler so you can just call a .scp file directly:

"c:\my documents\macro scheduler\calculator.scp"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

charleyhansen
Newbie
Posts: 2
Joined: Wed Nov 26, 2008 1:56 am

Access violation at address 006C99F4 in module 'msched.exe'.

Post by charleyhansen » Wed Nov 26, 2008 2:05 am

I have spent many hours trying to get image recognition function to work. It seem very neat, but the video shows it done in an older version of scheduler. I get the following message each time I get to the "findImagePos" step:
Access violation at address 006C99F4 in module 'msched.exe'. Read of address 00000054.
Has anyone else ran into this message?

thanks,
Charles

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

Post by Marcus Tettmar » Wed Nov 26, 2008 9:28 am

I've not seen this before.

Which version are you using?

Can you provide your script and image 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?

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Dec 08, 2008 8:19 pm

wow ive gotten that before and it wasnt macro scheduler that had the problem i had to update some dll files but i was on windows 98 when i got it i downloaded something to check my dll files and found a few that needed updates and once i updated em it fixed problem
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

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