junkone Posted April 2, 2008 Posted April 2, 2008 1. Try to do the same for calculator screen take twice a calculator snapshot. On my system it returns correct result2. Attach your 2 bitmapfiles to the post I can check then if the algorithm has an issue.Actually the result you get back means that there actually is only 1 matching line. To me it suggest(s) that your picture is off by one line or one pixel column and the second screenshot is not fully equal to the previous one taken.Is the title on your window exactly the same (no spaces added etc.)?hi. ok. i replaced my images that i was storing to compare and i get a true. however i need to understrand what this return code means.True;10;0;0;112;27;-1;-1 What does each of this parameter in this array mean.appreciate ur help.
junkew Posted April 2, 2008 Author Posted April 2, 2008 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
junkone Posted April 4, 2008 Posted April 4, 2008 True;10;0;0;112;27;-1;-1 What does each of this parameter in this array mean.appreciate ur help.I am not fully sure if you get a logical return value. Please post the BMP files you are trying to compare.return $bMatchPossible & ";" & $matchedLines & ";" & $foundAtLeft & ";" & $foundAtTop & ";" & $bmp2width & ";" & $BMP2Height & ";" & $HighestMatchingLines & ";" & $bestMatchLineTrue = It has a possible match found10 = Number of matched lines (so out of 27 lines 10 have matched)0,0,112,27 is the left,top, width, heights-1,-1 is the highest number of matching lines and returns the best matching linenumberAs the return values you get back do not seem logical to me (at least the -1 and -1 are not logical) I only can see whats happening if you attach the pictures to the posting.I did check the images and found they were not the ones i was looking for. then i did the same process again. using the following code twicewinactivate($targetHWND);_ScreenCapture_CaptureWnd($BitmapOriginalFile , $targetHWND)_ScreenCapture_CaptureWnd( $BitmapCurrentFile , $targetHWND)I get a true but not sure if it is a perfect match. i get a return code of "True;11;0;0;1160;819;3;11" for $tResult=findBMP($BitmapOriginalFile,$BitmapCurrentFile,False)i have attached both the pictures in teh zip file for you to compare.appreciate your helpcompare.zip
junkew Posted April 6, 2008 Author Posted April 6, 2008 ...i have attached both the pictures in teh zip file for you to compare.appreciate your helpObvious they are not equal Circuit, by name text is selected in the second picture and as such the pictures are not equal as the backgroundcolor of that text is blue. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
myspacee Posted April 14, 2008 Posted April 14, 2008 hello to all,if i use a webcam on 'digital' clock/temperature device is possible to 'find' value and return this to pc ?thank you for replym.
junkew Posted April 14, 2008 Author Posted April 14, 2008 Please start a topic in the support forum referencing to this example script. With the concepts used in this script you should be able to recognize whatever you have in your webcam screenshots. Search also - for OCR in the forum - for GetDIBits in the forum - for PixelSearch in the forum When you have the colorbits you can search for the colors you want to match and if they have a certain match it can recognize. I am not sure what you want to build but it sounds cheaper to buy a thermometer or clock you can directly connect to a computersystem FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
myspacee Posted April 14, 2008 Posted April 14, 2008 thank you for reply junkew,i think that you can 'teach' number before (snap shot number to 0 from 9)then search in webcam windows with your code...See this made in c# but not remember where.. (maybe or here)You think that you program can recognize number ?Sorry for bad english,m.
junkew Posted April 14, 2008 Author Posted April 14, 2008 The program can recognize bitmap in another bitmap only if its an exact match and with slight modification you can do partial match.It was mainly designed to recognize screen areas.Its not a computervision program like http://en.wikipedia.org/wiki/OpenCVAs you want to read thru webcam I think it will be very difficult because one slight change of angle will produce different bitmap and as such will become hard to recognize. Also background colors and light intensity will make it not likely that it will properly recognize.If you want to recognize numbers you should save 10 bmp files (snapshot of numbers 0-9) and search every time in your webcam screenshot.It will be easier to give an answer to your question if you post your webcam screenshots for an example. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
ludocus Posted May 18, 2008 Posted May 18, 2008 gives me error: CODEC:\Documents and Settings\Ludo\Bureaublad\testje.au3 (54) : ==> Array variable subscript badly formatted.: ReDim $fline[$BMP2Height] ReDim $fline[^ ERROR ->20:40:03 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 4.788
junkew Posted June 12, 2008 Author Posted June 12, 2008 Verified with newest version of AutoIt 3.2.12 and works Updated some of the code and cleaner samples FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Kitsune Posted June 13, 2008 Posted June 13, 2008 I was just looking through this thread and saw the posts about the false with the B&W samples. If you looked closely at the images you'd notice that there are compression artifacts present in sample B that are not present in sample A, which would probably be the reason that there were false "falses". Perhaps a possible workaround would be to invert both the sample being searched for and the area being tested and perform an XOR operation then invert the result and find the average of all pixels in the result, divide by 255 to get the % of the match which in this case would probably be at least 98%. Close enough to be considered a match. Although I'm just throwing in this idea is all that would be needed for a simple snippet to get the % of a match that would be more accurate than the result of PixelCheckSum() (I'm assuming that this function returns the average color of the region and the script is having that average checked against the average of the image being searched for). Just let me know if I'm just spouting BS due to being tired, although you may as well give it a shot just to show that you're open to any ideas.
junkew Posted August 31, 2008 Author Posted August 31, 2008 Will later look into the lockbits solution to find quicker on a screenbitmaphttp://www.autoitscript.com/forum/index.php?showtopic=78645 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
junkew Posted September 4, 2008 Author Posted September 4, 2008 Updated full source code of first post * Finds a bitmap (.BMP) in another BMP file (other formats BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF should work but not tested) * Based now on GDI plus functions * Speed enhancements (mainly by making 16 bits or 24 bits picture) * Assuming speed can be more enhanced when after match is found on first line a bitblt with srcinvert should do the trick but this needs more rewriting of the algorithm (keeping the HBitmap DC in memory). * Partial match works fast enough and doesn't give me on screen false positives so far FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
therms Posted September 30, 2008 Posted September 30, 2008 .au3 (62) : ==> Subscript used with non-Array variable.: _ScreenCapture_Capture($Bitmap3Filename, ($aWinPos[0]+$pos[0]) + ($aWinPos[2] - $aWinCSize[0])-3, ($awinpos[1]+$pos[1])+ ($aWinPos[3]-$aWinCSize[1])-3, $aWinPos[0]+$pos[0]+$pos[2]+3, ($awinpos[1]+$pos[1])+ ($aWinPos[3]-$aWinCSize[1])+$pos[3]-3,false) _ScreenCapture_Capture($Bitmap3Filename, ($aWinPos[0]+$pos^ ERROR I get that whilst running the example code...
junkew Posted October 2, 2008 Author Posted October 2, 2008 Most likely the calculator does not start or the BACKSPACE button is not found $pos=controlgetpos("","","[CLASS:Button; TEXT:BACKSPACE]") Check if calculator starts and has a button with text BACKSPACE. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Ghost21 Posted November 6, 2008 Posted November 6, 2008 What about Screen Resolution Change ? If you take a picture on a 1280 x 1024 and say the picture is 90x25 then you run the same picture captured on a 1280x1024 and goto a 1024x768 is it going to find it or have some crazy issues... ??
Zedna Posted November 6, 2008 Posted November 6, 2008 (edited) Nice! I tested this baby and changed it to UDF and corrected BACKSPACE to Backspace (in case of my PC). It seems to work fine except situation when image is not found. Then it will crash instead of correct False return value, see this output Saving calculator window 282.693750183333 milliseconds Saving backspacebutton 13.4260080540963 milliseconds Saving full screen took 87.2839983852696 milliseconds 768 Searching took 0.213531887432621 seconds True;11;0;0;1024;768;-1;-1 FULLSCREEN.bmp in FULLSCREEN.bmp ** matchtype 2 time elapsed: 724.313564992199 milliseconds768 Searching took 0.14057792261307 seconds True;11;0;0;1024;768;-1;-1 FULLSCREEN.bmp in FULLSCREEN.bmp ** matchtype 4 time elapsed: 495.038335877884 milliseconds254 Searching took 3.23241780729115 seconds True;252;22;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 1 time elapsed: 3548.79516810097 milliseconds254 Searching took 0.911740458633709 seconds True;11;22;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 2 time elapsed: 1228.32901947035 milliseconds254 Searching took 2.01032058543753 seconds True;252;15;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 3 time elapsed: 2225.04647937098 milliseconds254 Searching took 0.467206586311947 seconds True;11;15;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 4 time elapsed: 701.886412937957 milliseconds254 Searching took 2.01967400884749 seconds True;252;15;491;260;254;1;19 CALCULATOR.bmp in FULLSCREEN.bmp ** matchtype 3 time elapsed: 2217.99642133288 milliseconds254 Searching took 0.462936211166503 seconds True;11;15;491;260;254;1;19 CALCULATOR.bmp in FULLSCREEN.bmp ** matchtype 4 time elapsed: 657.174864403157 milliseconds29 Searching took 0.0756920223100981 seconds True;28;38;145;63;29;-1;-1 BACKSPACE.bmp in CALCULATOR.bmp ** matchtype 3 time elapsed: 89.9133828461438 milliseconds29 Searching took 0.0896315034452703 seconds True;10;38;145;63;29;-1;-1 BACKSPACE.bmp in CALCULATOR.bmp ** matchtype 4 time elapsed: 107.860356553696 milliseconds29 Searching took 0.591752024349463 seconds True;27;53;636;63;29;1;84 BACKSPACE.bmp in SCREEN ** matchtype 3 time elapsed: 807.142807256229 milliseconds29 Searching took 0.493043389592811 seconds True;10;53;636;63;29;1;84 BACKSPACE.bmp in SCREEN ** matchtype 4 time elapsed: 724.325018961907 milliseconds0 findBMP.au3 (63) : ==> Array variable subscript badly formatted.: ReDim $fline[$BMP2Height] ReDim $fline[^ ERROR I think something like this should help: If $BMP2Height = 0 Then SetError(1,0,0) Return False EndIf ReDim $fline[$BMP2Height] EDIT: there are also error messageboxes: "Error locking region 2" see this output from script corrected by above checking "$BMP2Height = 0 " Saving calculator window 527.083190740723 milliseconds Saving backspacebutton 20.5210438756881 milliseconds Saving full screen took 101.765168478117 milliseconds Searching took 0.195965129646366 seconds True;11;0;0;1024;768;-1;-1 FULLSCREEN.bmp in FULLSCREEN.bmp ** matchtype 2 time elapsed: 703.918235418189 milliseconds Searching took 0.129234022759876 seconds True;11;0;0;1024;768;-1;-1 FULLSCREEN.bmp in FULLSCREEN.bmp ** matchtype 4 time elapsed: 484.127731317807 milliseconds Searching took 3.12042452322851 seconds True;252;22;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 1 time elapsed: 3426.84447325009 milliseconds Searching took 0.864917468560948 seconds True;11;22;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 2 time elapsed: 1165.5612654681 milliseconds Searching took 1.97953818152866 seconds True;252;15;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 3 time elapsed: 2194.66915487862 milliseconds Searching took 0.431106188076976 seconds True;11;15;491;260;254;1;19 CALCULATOR.bmp in SCREEN ** matchtype 4 time elapsed: 646.660958306153 milliseconds Searching took 1.94045025275559 seconds True;252;15;491;260;254;1;19 CALCULATOR.bmp in FULLSCREEN.bmp ** matchtype 3 time elapsed: 2134.01759162128 milliseconds Searching took 0.43397275352035 seconds True;11;15;491;260;254;1;19 CALCULATOR.bmp in FULLSCREEN.bmp ** matchtype 4 time elapsed: 627.626416206529 milliseconds Searching took 0.0661810369753698 seconds True;28;38;145;63;29;-1;-1 BACKSPACE.bmp in CALCULATOR.bmp ** matchtype 3 time elapsed: 84.0433630531255 milliseconds Searching took 0.0674934942848882 seconds True;10;38;145;63;29;-1;-1 BACKSPACE.bmp in CALCULATOR.bmp ** matchtype 4 time elapsed: 87.7767984478474 milliseconds Searching took 0.570028872384619 seconds True;27;53;636;63;29;1;84 BACKSPACE.bmp in SCREEN ** matchtype 3 time elapsed: 781.978156441671 milliseconds Searching took 0.467530091114932 seconds True;10;53;636;63;29;1;84 BACKSPACE.bmp in SCREEN ** matchtype 4 time elapsed: 684.338651979511 milliseconds False SEVEN_BW.bmp in 7WDS_BW.bmp ** matchtype 3 time elapsed: 5804.93861650014 milliseconds False SEVEN_BW.bmp in 7WDS_BW.bmp ** matchtype 4 time elapsed: 1198.30313629246 milliseconds False CAT_BW.bmp in 7WDS_BW.bmp ** matchtype 3 time elapsed: 1136.16730617998 milliseconds False CAT_BW.bmp in 7WDS_BW.bmp ** matchtype 4 time elapsed: 1965.46767815463 milliseconds False AUTOIT3.bmp in FULLSCREEN.bmp ** matchtype 3 time elapsed: 1574.92586348265 milliseconds Edited November 6, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Armand Posted November 7, 2008 Posted November 7, 2008 well.. i'll re'test it later.... hopefully it'll work better then it did 2 months or so ago.... this script can be of great great great use to make a proper OCR [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!
junkew Posted November 23, 2008 Author Posted November 23, 2008 (edited) What about Screen Resolution Change ? If you take a picture on a 1280 x 1024 and say the picture is 90x25 then you run the same picture captured on a 1280x1024 and goto a 1024x768 is it going to find it or have some crazy issues... ??On BMP format it will not work.On the other hand it could work for EMF/WMF files as they should be device independent and if I am correct will then work with 96 DPI as its all based on GDIPlus.See for screen resolution changing http://www.autoitscript.com/forum/index.ph...mp;#entry509276Unfortunately not much time to try* The matching algorithm could be changed with a calculation but thats at least for my purpose not needed (I will make sure screen settings are the same on computers I want to use this). Edited November 23, 2008 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
junkew Posted November 23, 2008 Author Posted November 23, 2008 Nice! I tested this baby and changed it to UDF and corrected BACKSPACE to Backspace (in case of my PC). It seems to work fine except situation when image is not found. Then it will crash instead of correct False return value, see this output I think something like this should help: If $BMP2Height = 0 Then SetError(1,0,0) Return False EndIf ReDim $fline[$BMP2Height] EDIT: there are also error messageboxes: "Error locking region 2" see this output from script corrected by above checking "$BMP2Height = 0 " * Added the code to check * The error is more or less a painfull one happening more on GDIPLUS when I search in Google. Without a one direction resolution. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now