Recognition faster

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jimbo25
Newbie
Posts: 2
Joined: Sat Oct 27, 2007 1:00 pm

Recognition faster

Post by Jimbo25 » Sat Oct 27, 2007 1:18 pm

Hi,

I'm searching a way to click text in flash as fast as possible.

The flash file displays random words, if a word matches one of my 300 words than it needs to be clicked in a fraction of a second.

Because it's flash text, I assume you can only handle it as images. So I'll have to use Image recognition.

I tried your software with 1 image but it takes several seconds... Is it unrealistic to look for 300 images at the same time, and if one is displayed, it has to be found and clicked in less than a second?

The flash text/image can only be displayed in a small part of my screen. Can I set the search boundaries or something? What image will be found faster, big or small one?

Could you point me in the right direction if your software isn't made for this.

Thanks,
Jimbo

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

Post by Marcus Tettmar » Sat Oct 27, 2007 3:53 pm

Yes, with Flash you need to use image recognition.

It may take more than one second to identify an image on the entire screen, but you don't have to search the full screen. That is inefficient. It would be much faster if the area you are searching in is smaller. You can capture just the window, or even a specific area of the window and then search within that smaller bitmap.

Clearly image recognition is a fairly resource intensive process. It is only in the last 2 or 3 years that it has even been feasible. We've made it as fast as possible without losing too much accuracy. In most cases, on a reasonably well specced modern PC, scanning a window for an object takes no more than a second. A faster PC will of course make a big difference. But you may be expecting a bit much if you want to be able to capture the whole screen and scan it all within a fraction of a second, and then do it all over again in the next second.

Of course doing it in assembly language is going to be faster than in C++ which is going to be faster than doing it in a high level macro language. So, yes, perhaps for your needs, Macro Scheduler is not the solution. Macro Scheduler is designed for simplifying automation tasks not high-speed video processing.

Another thing to consider is whether you can slow down the Flash process in some way, instead of, or as well as speeding up the capture process.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Jimbo25
Newbie
Posts: 2
Joined: Sat Oct 27, 2007 1:00 pm

Post by Jimbo25 » Sun Oct 28, 2007 11:45 am

Thanks for your time. Great reply.
Another thing to consider is whether you can slow down the Flash process in some way
Any idea how?

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

Post by Marcus Tettmar » Sun Oct 28, 2007 2:32 pm

Lower the priority of the process? Run it on a Virtual PC with limited RAM?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

jserini
Newbie
Posts: 2
Joined: Fri Nov 09, 2007 5:24 am

Post by jserini » Fri Nov 09, 2007 6:08 am

This is very much the same thing I need to do, but I only need it to look through around 15 different words, or images. And the screen area I need to search is only around 400x400.


I tried

ScreenCapture>600,600,1000,1000,c:\s\screen.bmp
FindImagePos>C:\s\eagle.bmp,C:\s\screen.bmp,1,1,X,Y,wrd
If>wrd>0
MouseMove>X_0,X_0
LClick
Endif

This of course only checks for a single image, and also preforms the LClick way up in the left corner, rather than the center of where it found the image.

So how should I go about doing that?

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

Post by Marcus Tettmar » Fri Nov 09, 2007 8:48 am

The mouse click needs to be offset against the area you captured. You didn't capture the entire screen - you started at 600x600. So you should add 600x600 to the mouse coordinates, as the MouseMove works against the screen:

Let>X=X_0+600
Let>Y=Y_0+600
MouseMove>X,Y
LClick
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

jserini
Newbie
Posts: 2
Joined: Fri Nov 09, 2007 5:24 am

Post by jserini » Fri Nov 09, 2007 9:10 am

Ah. Thanks a bunch, for some reason I thought it was suppose to center on where it found the image.

What would be the quickest way to check the area for a list of images?

This works, but is there a quicker way to do it?

ScreenCapture>620,620,955,805,c:\s\screen.bmp
FindImagePos>C:\s\eagleeye.bmp,C:\s\screen.bmp,10,1,X,Y,eagle
FindImagePos>C:\s\sweetdreams.bmp,C:\s\screen.bmp,10,1,X,Y,sweet
FindImagePos>C:\s\white.bmp,C:\s\screen.bmp,10,1,X,Y,white
If>eagle>0
Let>X=X_0+620
Let>Y=Y_0+620
MouseMove>X,Y
LClick
Endif

If>sweet>0
Let>X=X_0+620
Let>Y=Y_0+620
MouseMove>X,Y
LClick
Endif

If>white>0
Let>X=X_0+620
Let>Y=Y_0+620
MouseMove>X,Y
LClick
Endif

...

And like the original poster asked, what effect does the size of the image you look for have on the time it takes? Should it be as small as possible, or fixed max width, so it only needs to compare downwards rather then every possible 50x50 pixles. Or however large the image might be.

Again, thank you.

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

Post by Marcus Tettmar » Fri Nov 09, 2007 10:10 am

Ah. Thanks a bunch, for some reason I thought it was suppose to center on where it found the image.
It centers on the image found. It returns the coordinates of one image in another.

It didn't know that the image you asked it to search was PART of the screen. It just searches for one image in another and returns the coordinates of the main image. Since the image you asked it to search was part of the screen you need to translate the coordinates back to screen coordinates.

If, however, you searched the ENTIRE screen or used SCREEN for the haystack then clearly no translation is necessary.

I hope that makes sense.
What would be the quickest way to check the area for a list of images?

This works, but is there a quicker way to do it?
Not really. Scanning an image three times for three different images requires a little bit of processing time. I'm afraid we cannot expect that to be instantaneous.
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