Image Recognition - type result - need help

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
thewanderer
Newbie
Posts: 1
Joined: Mon Jan 03, 2011 6:22 pm

Image Recognition - type result - need help

Post by thewanderer » Tue Jan 04, 2011 7:58 pm

BASED ON: http://www.mjtnet.com/blog/2007/02/20/h ... cognition/
Im using MS v 12, windows vista. So there's this one game thing that loads 3 images at the same time, they're numbers 1-9, you have to type them in left to right. They repeat alot in the end so their library ain't that big. looks something like this:
http://img5.imageshack.us/img5/1475/exmaple.jpg
I put it in a corner so only 1 image shows up at a time.. (left one)
making a program for this doesn't seem too complicated... to one that knows what they're doing lol, I'm a big ol rookie in need of Help! I really need to get things explained/pointed in the right direction. So here's the script I made:

Code: Select all

Label>Begin
Clear
GetScreenRes>sX,sY
ScreenCapture>0,0,sX,sY,d:\screen.bmp
FindImagePos>C:\Users\Misa\Documents\AppNav\1\1.bmp,SCREEN,80,1,XPos,YPos,imgs1
FindImagePos>C:\Users\Misa\Documents\AppNav\1b\1.bmp,SCREEN,80,1,XPos,YPos,imgs1b
FindImagePos>C:\Users\Misa\Documents\AppNav\1g\1.bmp,SCREEN,80,1,XPos,YPos,imgs1g
FindImagePos>C:\Users\Misa\Documents\AppNav\1\1two.bmp,SCREEN,80,1,XPos,YPos,imgs1two
FindImagePos>C:\Users\Misa\Documents\AppNav\1\1one.bmp,SCREEN,80,1,XPos,YPos,imgs1one
FindImagePos>C:\Users\Misa\Documents\AppNav\1\10.bmp,SCREEN,80,1,XPos,YPos,imgs10
FindImagePos>C:\Users\Misa\Documents\AppNav\1\11.bmp,SCREEN,80,1,XPos,YPos,imgs11
FindImagePos>C:\Users\Misa\Documents\AppNav\1\12.bmp,SCREEN,80,1,XPos,YPos,imgs12
FindImagePos>C:\Users\Misa\Documents\AppNav\1\111.bmp,SCREEN,80,1,XPos,YPos,imgs111
FindImagePos>C:\Users\Misa\Documents\AppNav\1\13.bmp,SCREEN,80,1,XPos,YPos,imgs13
FindImagePos>C:\Users\Misa\Documents\AppNav\1\14.bmp,SCREEN,80,1,XPos,YPos,imgs14

FindImagePos>C:\Users\Misa\Documents\AppNav\2\2.bmp,SCREEN,40,1,XPos,YPos,imgs2
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2a.bmp,SCREEN,40,1,XPos,YPos,imgs2a
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2b.bmp,SCREEN,40,1,XPos,YPos,imgs2b
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2c.bmp,SCREEN,40,1,XPos,YPos,imgs2c
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2d.bmp,SCREEN,40,1,XPos,YPos,imgs2d
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2e.bmp,SCREEN,40,1,XPos,YPos,imgs2e
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2f.bmp,SCREEN,40,1,XPos,YPos,imgs2f
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2g.bmp,SCREEN,40,1,XPos,YPos,imgs2g
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2t.bmp,SCREEN,40,1,XPos,YPos,imgs2t
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2v.bmp,SCREEN,40,1,XPos,YPos,imgs2v
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2z.bmp,SCREEN,40,1,XPos,YPos,imgs2z
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2one.bmp,SCREEN,40,1,XPos,YPos,imgs2one
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2two.bmp,SCREEN,40,1,XPos,YPos,imgs2two
FindImagePos>C:\Users\Misa\Documents\AppNav\2\20.bmp,SCREEN,40,1,XPos,YPos,imgs20
FindImagePos>C:\Users\Misa\Documents\AppNav\2\22.bmp,SCREEN,40,1,XPos,YPos,imgs22
FindImagePos>C:\Users\Misa\Documents\AppNav\2\29.bmp,SCREEN,40,1,XPos,YPos,imgs29
FindImagePos>C:\Users\Misa\Documents\AppNav\2\2pn.bmp,SCREEN,40,1,XPos,YPos,imgs2pn

FindImagePos>C:\Users\Misa\Documents\AppNav\3\3.bmp,SCREEN,90,1,XPos,YPos,imgs3
FindImagePos>C:\Users\Misa\Documents\AppNav\3\3two.bmp,SCREEN,90,1,XPos,YPos,imgs3two
FindImagePos>C:\Users\Misa\Documents\AppNav\3\3one.bmp,SCREEN,90,1,XPos,YPos,imgs3one
FindImagePos>C:\Users\Misa\Documents\AppNav\3\3three.bmp,SCREEN,90,1,XPos,YPos,imgs3three
FindImagePos>C:\Users\Misa\Documents\AppNav\3\31.bmp,SCREEN,90,1,XPos,YPos,imgs31
FindImagePos>C:\Users\Misa\Documents\AppNav\3\33.bmp,SCREEN,90,1,XPos,YPos,imgs33
FindImagePos>C:\Users\Misa\Documents\AppNav\3\311.bmp,SCREEN,90,1,XPos,YPos,imgs311
FindImagePos>C:\Users\Misa\Documents\AppNav\3\3pn.bmp,SCREEN,90,1,XPos,YPos,imgs3pn

FindImagePos>C:\Users\Misa\Documents\AppNav\4\4one.bmp,SCREEN,40,1,XPos,YPos,imgs4one
FindImagePos>C:\Users\Misa\Documents\AppNav\4\4two.bmp,SCREEN,40,1,XPos,YPos,imgs4two
FindImagePos>C:\Users\Misa\Documents\AppNav\4\40.bmp,SCREEN,40,1,XPos,YPos,imgs40
FindImagePos>C:\Users\Misa\Documents\AppNav\4\41.bmp,SCREEN,40,1,XPos,YPos,imgs41
FindImagePos>C:\Users\Misa\Documents\AppNav\4\42.bmp,SCREEN,40,1,XPos,YPos,imgs42
FindImagePos>C:\Users\Misa\Documents\AppNav\4\44.bmp,SCREEN,40,1,XPos,YPos,imgs44
FindImagePos>C:\Users\Misa\Documents\AppNav\4\411.bmp,SCREEN,40,1,XPos,YPos,imgs411

FindImagePos>C:\Users\Misa\Documents\AppNav\5\5.bmp,SCREEN,30,1,XPos,YPos,imgs5
FindImagePos>C:\Users\Misa\Documents\AppNav\5\5one.bmp,SCREEN,30,1,XPos,YPos,imgs5one
FindImagePos>C:\Users\Misa\Documents\AppNav\5\5two.bmp,SCREEN,30,1,XPos,YPos,imgs5two
FindImagePos>C:\Users\Misa\Documents\AppNav\5\51.bmp,SCREEN,30,1,XPos,YPos,imgs51
FindImagePos>C:\Users\Misa\Documents\AppNav\5\5three.bmp,SCREEN,30,1,XPos,YPos,imgs5three
FindImagePos>C:\Users\Misa\Documents\AppNav\5\50.bmp,SCREEN,30,1,XPos,YPos,imgs50
FindImagePos>C:\Users\Misa\Documents\AppNav\5\52.bmp,SCREEN,30,1,XPos,YPos,imgs52
FindImagePos>C:\Users\Misa\Documents\AppNav\5\53.bmp,SCREEN,30,1,XPos,YPos,imgs53
FindImagePos>C:\Users\Misa\Documents\AppNav\5\54.bmp,SCREEN,30,1,XPos,YPos,imgs54
FindImagePos>C:\Users\Misa\Documents\AppNav\5\55.bmp,SCREEN,30,1,XPos,YPos,imgs55
FindImagePos>C:\Users\Misa\Documents\AppNav\5\522.bmp,SCREEN,30,1,XPos,YPos,imgs522
FindImagePos>C:\Users\Misa\Documents\AppNav\5\533.bmp,SCREEN,30,1,XPos,YPos,imgs533

FindImagePos>C:\Users\Misa\Documents\AppNav\6\6.bmp,SCREEN,40,1,XPos,YPos,imgs6
FindImagePos>C:\Users\Misa\Documents\AppNav\6\60.bmp,SCREEN,40,1,XPos,YPos,imgs60
FindImagePos>C:\Users\Misa\Documents\AppNav\6\61.bmp,SCREEN,40,1,XPos,YPos,imgs61
FindImagePos>C:\Users\Misa\Documents\AppNav\6\62.bmp,SCREEN,40,1,XPos,YPos,imgs62
FindImagePos>C:\Users\Misa\Documents\AppNav\6\63.bmp,SCREEN,40,1,XPos,YPos,imgs63
FindImagePos>C:\Users\Misa\Documents\AppNav\6\64.bmp,SCREEN,40,1,XPos,YPos,imgs64
FindImagePos>C:\Users\Misa\Documents\AppNav\6\65.bmp,SCREEN,40,1,XPos,YPos,imgs65
FindImagePos>C:\Users\Misa\Documents\AppNav\6\66.bmp,SCREEN,40,1,XPos,YPos,imgs66
FindImagePos>C:\Users\Misa\Documents\AppNav\6\622.bmp,SCREEN,40,1,XPos,YPos,imgs622
FindImagePos>C:\Users\Misa\Documents\AppNav\6\6a.bmp,SCREEN,40,1,XPos,YPos,imgs6a
FindImagePos>C:\Users\Misa\Documents\AppNav\6\6m.bmp,SCREEN,40,1,XPos,YPos,imgs6m
FindImagePos>C:\Users\Misa\Documents\AppNav\6\6n.bmp,SCREEN,40,1,XPos,YPos,imgs6n
FindImagePos>C:\Users\Misa\Documents\AppNav\6\6t.bmp,SCREEN,40,1,XPos,YPos,imgs6t
FindImagePos>C:\Users\Misa\Documents\AppNav\6\6v.bmp,SCREEN,40,1,XPos,YPos,imgs6v

FindImagePos>C:\Users\Misa\Documents\AppNav\7\7.bmp,SCREEN,70,1,XPos,YPos,imgs7
FindImagePos>C:\Users\Misa\Documents\AppNav\7\7one.bmp,SCREEN,70,1,XPos,YPos,imgs7one
FindImagePos>C:\Users\Misa\Documents\AppNav\7\71.bmp,SCREEN,70,1,XPos,YPos,imgs71
FindImagePos>C:\Users\Misa\Documents\AppNav\7\72.bmp,SCREEN,70,1,XPos,YPos,imgs72
FindImagePos>C:\Users\Misa\Documents\AppNav\7\73.bmp,SCREEN,70,1,XPos,YPos,imgs73
FindImagePos>C:\Users\Misa\Documents\AppNav\7\74.bmp,SCREEN,70,1,XPos,YPos,imgs74
FindImagePos>C:\Users\Misa\Documents\AppNav\7\77.bmp,SCREEN,70,1,XPos,YPos,imgs77
FindImagePos>C:\Users\Misa\Documents\AppNav\7\78.bmp,SCREEN,70,1,XPos,YPos,imgs78
FindImagePos>C:\Users\Misa\Documents\AppNav\7\79.bmp,SCREEN,70,1,XPos,YPos,imgs79
FindImagePos>C:\Users\Misa\Documents\AppNav\7\7a.bmp,SCREEN,70,1,XPos,YPos,imgs7a
FindImagePos>C:\Users\Misa\Documents\AppNav\7\7b.bmp,SCREEN,70,1,XPos,YPos,imgs7b
FindImagePos>C:\Users\Misa\Documents\AppNav\7\7c.bmp,SCREEN,70,1,XPos,YPos,imgs7c
FindImagePos>C:\Users\Misa\Documents\AppNav\7\7d.bmp,SCREEN,70,1,XPos,YPos,imgs7d

FindImagePos>C:\Users\Misa\Documents\AppNav\8\8two.bmp,SCREEN,40,1,XPos,YPos,imgs8two
FindImagePos>C:\Users\Misa\Documents\AppNav\8\81.bmp,SCREEN,40,1,XPos,YPos,imgs81
FindImagePos>C:\Users\Misa\Documents\AppNav\8\82.bmp,SCREEN,40,1,XPos,YPos,imgs82
FindImagePos>C:\Users\Misa\Documents\AppNav\8\83.bmp,SCREEN,40,1,XPos,YPos,imgs83
FindImagePos>C:\Users\Misa\Documents\AppNav\8\88.bmp,SCREEN,40,1,XPos,YPos,imgs88
FindImagePos>C:\Users\Misa\Documents\AppNav\8\811.bmp,SCREEN,40,1,XPos,YPos,imgs811
FindImagePos>C:\Users\Misa\Documents\AppNav\8\8222.bmp,SCREEN,40,1,XPos,YPos,imgs8222
FindImagePos>C:\Users\Misa\Documents\AppNav\8\822.bmp,SCREEN,40,1,XPos,YPos,imgs822

FindImagePos>C:\Users\Misa\Documents\AppNav\9\9one.bmp,SCREEN,40,1,XPos,YPos,imgs9one
FindImagePos>C:\Users\Misa\Documents\AppNav\9\9two.bmp,SCREEN,40,1,XPos,YPos,imgs9two
FindImagePos>C:\Users\Misa\Documents\AppNav\9\9three.bmp,SCREEN,40,1,XPos,YPos,imgs9three
FindImagePos>C:\Users\Misa\Documents\AppNav\9\92.bmp,SCREEN,40,1,XPos,YPos,imgs92
FindImagePos>C:\Users\Misa\Documents\AppNav\9\93.bmp,SCREEN,40,1,XPos,YPos,imgs93
FindImagePos>C:\Users\Misa\Documents\AppNav\9\94.bmp,SCREEN,40,1,XPos,YPos,imgs94
FindImagePos>C:\Users\Misa\Documents\AppNav\9\98.bmp,SCREEN,40,1,XPos,YPos,imgs98
FindImagePos>C:\Users\Misa\Documents\AppNav\9\99.bmp,SCREEN,40,1,XPos,YPos,imgs99
FindImagePos>C:\Users\Misa\Documents\AppNav\9\922.bmp,SCREEN,40,1,XPos,YPos,imgs922
FindImagePos>C:\Users\Misa\Documents\AppNav\9\999.bmp,SCREEN,40,1,XPos,YPos,imgs999
Wait>2

    If>imgs9one>0
        Send>9
        Goto>Begin
    Endif

    If>imgs9three>0
        Send>9
        Goto>Begin
    Endif

    If>imgs9two>0
        Send>9
        Goto>Begin
    Endif

    If>imgs92>0
        Send>9
        Goto>Begin
    Endif

    If>imgs93>0
        Send>9
        Goto>Begin
    Endif

    If>imgs94>0
        Send>9
        Goto>Begin
    Endif
    
    If>imgs98>0
        Send>9
        Goto>Begin
    Endif

    If>imgs999>0
        Send>9
        Goto>Begin
    Endif

    If>imgs922>0
        Send>9
        Goto>Begin
    Endif

    If>imgs99>0
        Send>9
        Goto>Begin
    Endif

    If>imgs8two>0
        Send>8
    Endif

    If>imgs81>0
        Send>8
    Endif

    If>imgs82>0
        Send>8
    Endif

    If>imgs83>0
        Send>8
    Endif

    If>imgs88>0
        Send>8
    Endif

    If>imgs811>0
        Send>8
    Endif

    If>imgs822>0
        Send>8
    Endif

    If>imgs8222>0
        Send>8
    Endif

    If>imgs7>0
        Send>7
    Endif

    If>imgs7one>0

        Send>7
    Endif

    If>imgs71>0

        Send>7
    Endif

    If>imgs72>0

        Send>7
    Endif

    If>imgs73>0

        Send>7
    Endif

    If>imgs74>0

        Send>7
    Endif

    If>imgs77>0

        Send>7
    Endif

    If>imgs78>0

        Send>7
    Endif

    If>imgs79>0

        Send>7
    Endif
    
    If>imgs7a>0

        Send>7
    Endif
    
    If>imgs7b>0

        Send>7
    Endif
    
    If>imgs7c>0

        Send>7
    Endif
    
    If>imgs7d>0

        Send>7
    Endif

    If>imgs6>0

        Send>6
    Endif

    If>imgs60>0
        Send>6
    Endif

    If>imgs61>0

        Send>6
    Endif

    If>imgs62>0

        Send>6
    Endif
    
    If>imgs63>0
        Send>6
    Endif

    If>imgs64>0
        Send>6
    Endif
    
    If>imgs65>0
        Send>6
    Endif

    If>imgs66>0
        Send>6
    Endif

    If>imgs622>0
        Send>6
    Endif
    
    If>imgs6a>0
        Send>6
    Endif
    
    If>imgs6m>0
        Send>6
    Endif
    
    If>imgs6n>0
        Send>6
    Endif
    
    If>imgs6t>0
        Send>6
    Endif
    
    If>imgs6v>0
        Send>6
    Endif
    


    If>imgs5>0

        Send>5
    Endif

    If>imgs5one>0

        Send>5
    Endif

    If>imgs5two>0

        Send>5
    Endif

    If>imgs5three>0

        Send>5
    Endif

    If>imgs50>0

        Send>5
    Endif
    
    If>imgs51>0

        Send>6
    Endif

    If>imgs52>0

        Send>5
    Endif

    If>imgs53>0
        Send>5
    Endif

    If>imgs54>0
        Send>5
    Endif

    If>imgs55>0
        Send>5
    Endif

    If>imgs522>0
        Send>5
    Endif

    If>imgs533>0
        Send>5
    Endif

    If>imgs4one>0
        Send>4
    Endif

    If>imgs4two>0
        Send>4
    Endif

    If>imgs40>0
        Send>4
    Endif

    If>imgs41>0
        Send>4
    Endif

    If>imgs42>0
        Send>4
    Endif

    If>imgs44>0
        Send>4
    Endif

    If>imgs411>0
        Send>4
    Endif

    If>imgs3>0
        Send>3
    Endif

    If>imgs3one>0
        Send>3
    Endif

    If>imgs3two>0
        Send>3
    Endif

    If>imgs3three>0
        Send>3
    Endif

    If>imgs31>0
        Send>3
    Endif

    If>imgs311>0
        Send>3
    Endif

    If>imgs33>0
        Send>3
    Endif
    
    If>imgs3pn>0
        Send>3
    Endif
    
    If>imgs2>0
        Send>2
    Endif

    If>imgs2a>0
        Send>2
    Endif
    
    If>imgs2b>0
        Send>2
    Endif
    
    If>imgs2c>0
        Send>2
    Endif
    
    If>imgs2d>0
        Send>2
    Endif
    
    If>imgs2e>0
        Send>2
    Endif
    
    If>imgs2f>0
        Send>2
    Endif
    
    If>imgs2g>0
        Send>2
    Endif
    
    If>imgs2t>0
        Send>2
    Endif
    
    If>imgs2v>0
        Send>2
    Endif
    
    If>imgs2z>0
        Send>2
    Endif

    If>imgs2one>0
        Send>2
    Endif

    If>imgs2two>0
        Send>2
    Endif

    If>imgs20>0
        Send>2
    Endif

    If>imgs22>0
        Send>2
    Endif

    If>imgs29>0
        Send>2
    Endif
    
    If>imgspn>0
        Send>2
    Endif

    If>imgs1>0
        Send>1
        Goto>Begin
    Endif
    
    If>imgs1b>0
        Send>1
        Goto>Begin
    Endif
    
    If>imgs1g>0
        Send>1
        Goto>Begin
    Endif

    If>imgs1one>0
        Send>1
        Goto>Begin
    Endif
    
    If>imgs1two>0
        Send>1
        Goto>Begin
    Endif

    If>imgs10>0
        Send>1
        Goto>Begin
    Endif

    If>imgs11>0
        Send>1
        Goto>Begin
    Endif

    If>imgs12>0
        Send>1
        Goto>Begin
    Endif

    If>imgs111>0
        Send>1
        Goto>Begin
    Endif
    
    If>imgs13>0
        Send>1
        Goto>Begin
    Endif
    
    If>imgs14>0
        Send>1
        Goto>Begin
    Endif
    
    Goto>Begin
As you can see, the top consists of screencapturing and loading my library of numbers to find a match. I load all 1-9 numbers, the many versions i have. Then I throw a little IF-EndIf for every number, if it did show up, then the number will be typed.

* Am I even in the right track of what I want to do? Or should I try to set it up some other way? I doing this based on some small tutorial using outlook that i found around here..
* How do you set the % of 'likeness/equality/matching' of the images? Say if img1 looks 70% like whats on screen, then type whatever that # is. I noticed this part:
FindImagePos>C:\Users\Misa\Documents\AppNav\1\1.bmp,SCREEN,80,1,XPos,YPos,imgs1
the 80 in there being the color tolerance, not too sure how it works, but the higher (up to 200ish?) the less matching it has to be or something? Not really sure how it works.
*About the goto/when an image is found:
If>imgs9two>0
Send>9
Goto>Begin
Endif
Does that really work that simple? I want it so that when it finds the first match, that it doesn't keep reading down the script but rather types the # then goes back to the top Label>Begin (which should hit clear and read a new screen image) and start finding a match again. But if it didn't find it, it should keep going down the script.
*Is it possible to get a .png/gif image and have it look for that instead of plain .bmps? I tried putting a .png image in the findimagepos and it didn't wanna work.. something about it not being bmp
*I know, im capturing the whole screen instead of just the window i want to look at, that's fine with me, as I don't want to read all 3 numbers at the same time,.

I really am not sure how to do this, so i've got too many questions :P I'll throw 'em in as I come across them. Such a trip, its hard to even come up with the questions =P

Thanks in advanced!

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