Picture recognition

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Picture recognition

Post by guyash2 » Thu Apr 27, 2006 1:29 pm

Hi! :wink:
I want to program a macro and I need your help in order to do that.
The macro that I want to do will open the Windows Picture and Fax viewer and lclick on "next image" random number of times (until here I know how to do that).
all the pictures in the folder will be at the same size and color but every image has a different name of a football team, like these images:
http://img149.imageshack.us/img149/3785 ... ed13tj.png

http://img135.imageshack.us/img135/1420/untitled5bp.png

The macro needs to recognize the team and print (message>) the name of the team.
I don't want to do that with letters or words recognition. I thought about something like scaning all the pixels in the image and then compare it to a known sample of pixels, for example:
images that their size is 5X1 pixels. In this example I want to "catch" the five pixels and then "ask" the program if their colors are green, blue and whatever..

Thank you.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Apr 27, 2006 1:37 pm

If these images are "known", that is to say, they can be stored in a bitmap file on your system before you search them, then you should use the Image Recognition Library that you can download free here at MJTNET. Quite simple to use. You would simply store the images (.bmp) you wish to find, then write a script (which I can send, if you like) to:

1. take a screen shot of the current image
2. call the DLL to see if the StoredImage.bmp exists within the Screen.bmp
then have your script do whatever you like based on the result.

If the images are unknown, then you are probably better off taking a sampling of pixels with GetPixelColor> and taking your best guess as to the specific image being viewed.

What type application are you attempting to create? What is the end result?

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

ok..

Post by guyash2 » Thu Apr 27, 2006 9:35 pm

Hi!
Thank you for answering :lol:
I found another way to do that- I scan the picture in order to find how many pixels are in the black color.. and than I contact that, for example: "Maccabi Haifa" contains 900 black pixels and "Barcelona" conatains 500 black pixels.
The macro that I am writing nowadays should at the end to recognize sentences and to sort them according to their length.

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Apr 27, 2006 10:12 pm

Unless two images ever happen to have the same number of black pixels, in which case your method (if I understand it ) will fail. The Image Recognition Library REALLY is the best way to deal with this situation.

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

you're right

Post by guyash2 » Fri Apr 28, 2006 9:17 am

youe'r right.. if I have two images with the same number of black pixels my macro will fail... but I've checked that and I don't have this.
If I have I can "ask" if there is a black pixel in a specific location, which one image has a black pixel there and the other one doesn't have...

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Fri Apr 28, 2006 1:31 pm

....good luck with that method. There are many ways to create applications. I don't always pick the best route, but if you are analysing pixels, you should learn to use Image Recognition. It's a free download from MJTNET.com

please let me know if I can ever help you in the future.

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

thank you

Post by guyash2 » Fri Apr 28, 2006 10:59 pm

thank you for your kindness.
I in the meantime cope with that program because it's a simple one, but maybe in the future, when I program more complicated scripts I will have to use the picture recognition from the website.
But now I have another question (unrelated to the privious questions)- How do I press the spacebar? I saw that the key code for that is 32 but I don't know how to press that (like I "press enter", "press g" or whatever).

Thank you very very much :D

User avatar
JRL
Automation Wizard
Posts: 3505
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Apr 28, 2006 11:14 pm

Send>%space%
If you' re in version 8.0

Send> ".
If you're previous to version 8.0

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

thank you

Post by guyash2 » Sat Apr 29, 2006 8:22 am

thank you but it works just when I want to write space ( )...
If I have a video game that I need to press there the spacebar in order to do somthing in the game, it doesn't press the space bar... the "send>" command is just to write space ( ).
What can I do?

Thank you.

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

Post by Marcus Tettmar » Sat Apr 29, 2006 9:21 am

It's the same thing. Space is a character. The space key sends a space character. Just like the A key sends an A character. So Send>%space% is the same as Press Space would be if such a command existed. Same as Send>A would be the same as Press A if such a command existed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Apr 29, 2006 2:54 pm

It is also necessary that the correct window has the focus when you do Send>_ (_ is for the space bar character)
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

thank you

Post by guyash2 » Sat Apr 29, 2006 4:05 pm

thank you but it still doesn't work.
For example, look at this flash game:
http://www.miniclip.com/spaceinvaders.htm

When I press on the spacebar the spaceship shots but when I do that with macro scheduler and write "send> " nothing happens.

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

picture recognition

Post by guyash2 » Tue May 09, 2006 2:53 pm

Thanks to mtettmar I succedded in pressing the spacebar.
Now I need help with the picture recognition. I decided not to recognize a picture by its number of black pixels. I decided to use the Image Recognition Library plugin. I don't know hot to use it.
I have some pictures that are saved in my hard disk. This pictures (exactly these pictures) are in a website in a known location.
I want to program a script which take the picture in this known and defined location and than compare it to the other picture and tell me what is the number of the picture in the hard disk.

Thank you.

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

Post by Marcus Tettmar » Fri May 12, 2006 8:49 am

I decided to use the Image Recognition Library plugin. I don't know hot to use it.
Have you read the help file and looked at the examples that come with the library?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

guyash2
Junior Coder
Posts: 40
Joined: Thu May 05, 2005 2:45 pm

Yes...

Post by guyash2 » Fri May 12, 2006 9:36 am

Yes I read that and I still don't understand how to do that.. because the examples show the method of comparison with precens and I didn't understand this example... As I told the images are exactly the same and I don't need precents in order to compare them.

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