CeramicWeasel
Members-
Posts
13 -
Joined
-
Last visited
CeramicWeasel's Achievements
Seeker (1/7)
1
Reputation
-
PhilHibbs reacted to a post in a topic: Advanced Pixel Search Library
-
It's been a while since I've been back to check this thread, but I'm still using this library in almost every au3 project I do. Despite occasional bugs, it saves me so much work, and makes my scripts MUCH faster. I've downloaded a copy of your source from github and will try making sense of it if I find the time and motivation. Thanks for your contribution, it's much appreciated!
-
If they're not, then you'll still get some noise even after filtering. Using the filter method suggested by FastFrench, a Blue value of 63 (for example) that gets bumped to 64 by noise is still going to show up as different from one snapshot to the next after filtering. I think the earlier suggestion of putting a ShadeVariation on FFLocalizeChanges as a noise filter is the simplest and most effective solution.
-
Actually, NearestSpot should work too, and will be slightly faster since BestSpot will do 2 full searches before it even considers the ShadeVariation parameter.
-
How about using KeepChanges to blank out everything that hasn't changed, then follow up with BestSpot with a large shade variation that includes everything except black pixels. With BestSpot, specify something like a 10x10 area with a minimum of 30 matching pixels. This will hopefully be enough to ignore noise and give you a location for the change. Not perfect, but may work. You could drastically reduce noise by cartoonizing the snapshot, but you'll never completely eliminate noise with that technique. To do this you could loop through every pixel in the snapshot and "round" it's color to the nearest n'th shade (GetPixel -> Round -> SetPixel), but I don't know how fast that will be.
-
Thankyou, it all works perfectly now. No more issues with the pixel aspect ratio either.
-
Don't forget $DllName Problem solved! Thanks. Here is what I know: In v1.7 both JPG and BMP worked, although there were the black line and pixel aspect ratio problems with BMP, they were both viewable in WinXP and Win7. In v1.8 JPG works the same as before, in both WinXP and Win7. In v1.8 BMP works on WinXP and the black line problem is gone. However, on Win7 32bit the BMP files are no longer working. The file is created, but is empty (0KB) and not viewable by any program. There is no information in TRACER.txt to indicate a problem, and @error is not set. Here is the code I'm using: #include "FastFind.au3" AutoItSetOption("WinTitleMatchMode", 4) $FFhWnd = WinGetHandle("[ACTIVE]") FFSetWnd($FFhWnd) FFSnapShot(0, 0, 299, 149) FFSaveBMP("SaveImageTest", false) If @error Then MsgBox(0, "Error", "Error code: " & @error) FFSaveJPG("SaveImageTest", 85, false) If @error Then MsgBox(0, "Error", "Error code: " & @error)
-
Proposing new function : PixelColorChecksum
CeramicWeasel replied to Drin's topic in AutoIt Example Scripts
Could definitely be useful. Too slow using PixelGetColor, but with FastFind and a few tweaks to allow color variations, it can do the following on standard Win7 menus in about half a second: ............................................................................................................................................................................................... ...####..#..#......................####......#..#.....................###........................#...................#.....#.#..............................######................#............ ...#........#......................#.........#.....#.................#...........................#....................#...#....................................#..................#............ ...#........#......................#.........#.....#.................#...........................#....................#...#....................................#..................#............ ...#.....#..#...###................#......####..######...............##.....###..####..###..###..#####................#...#..#...###.#...#...#.................#.....###....###...#..###....... ...####..#..#..#...#...............####..#..##..#..#..................##...#...#....#..##..##....##..#................##.#...#..#...#.#..##.##.................#....#...#..#...#..#..#......... ...#.....#..#..#####...............#.....#...#..#..#....................#..#####..###..#...#.....#...#.................#.#...#..#####.#.###.#..................#....#...#..#...#..#..#......... ...#.....#..#..#...................#.....#...#..#..#....................##.#.....#..#..#...#.....#...#.................###...#..#.....###.###..................#....#...#..#...#..#...##....... ...#.....#..#..#...................#.....#..##..#..#....................#..#.....#..#..#...#.....#...#.................##....#..#.....##..##...................#....#...#..#...#..#....#....... ...#.....#..#...####...............####...####..#..###...............####...####.####..#....###..#...#..................#....#...####..#...#...................#.....###....###...#..###....... ............................................................................................................................................................................................... #include "FastFind.au3" #Include <Color.au3> ConsoleWrite( "0x" & Hex( PixelColorChecksum( 0x000000, 5, 26, 195, 36, 205 ), 8 ) & @CRLF ) Func PixelColorChecksum( $iColor, $iLeft, $iTop, $iRight, $iBottom, $iVariation = 0 ) Local Const $iMOD_ADLER = 65521 Local $iA = 1, $iB = 0, $iRow, $iCol Local $sStr = "" FFSnapShot($iLeft, $iTop, $iRight, $iBottom) For $iRow = $iTop to $iBottom For $iCol = $iLeft To $iRight If _ColorInBounds(FFGetPixel( $iCol, $iRow ), $iColor, $iVariation) Then $iA = Mod( $iA + ( $iCol - $iLeft + 1 ) + ( $iRow - $iTop ) * ( $iRight - $iLeft + 1 ), $iMOD_ADLER ) $iB = Mod( $iB + $iA, $iMOD_ADLER ) $sStr = $sStr & "#" Else $sStr = $sStr & "." EndIf Next $sStr = $sStr & @LF Next ConsoleWrite( $sStr & @CRLF) Return BitOR( BitShift($iB, -16), $iA) - 1 EndFunc Func _ColorInBounds(Const $iColorFound, Const $iColor, Const $iVariation) Local $iRedFound = _ColorGetRed($iColorFound) Local $iGreenFound = _ColorGetGreen($iColorFound) Local $iBlueFound = _ColorGetBlue($iColorFound) Local $iRed = _ColorGetRed($iColor) Local $iGreen = _ColorGetGreen($iColor) Local $iBlue = _ColorGetBlue($iColor) Local $iR = Abs($iRedFound - $iRed) Local $iG = Abs($iGreenFound - $iGreen) Local $iB = Abs($iBlueFound - $iBlue) If ($iR <= $iVariation) AND ($iG <= $iVariation) AND ($iB <= $iVariation) Then Return 1 Else Return 0 EndIf EndFunc -
Thanks FastFrench! I'm not getting that "Can't Start" error anymore, so I can now use FastFind as a standard replacement for PixelGetColor and PixelSearch in all my scripts. Awesome stuff. The current version and dll names in the FastFind.au3 need to be updated in v1.8. Then how does it decide which snapshot to add the exclusion zone to? And why pass the window handle? I get the same behaviour when I use a snapshot like this, so I don't think that's the problem: #include "FastFind.au3" AutoItSetOption("WinTitleMatchMode", 4) $handle = WinActivate("[CLASS:Notepad]") FFSetWnd($handle) FFSnapShot(0, 0, 299, 149) FFAddExcludedArea(0, 0, 10, 10) If FFIsExcluded(5, 5, $handle) Then MsgBox(0, "Exclusion", "5,5 is excluded!") Else MsgBox(0, "Exclusion", "5,5 is NOT excluded!") EndIf This is not working on Win7 32bit. It produces an empty 0KB file. I think it works okay on WinXP, because I tried it out on my work computer earlier today, and I didn't notice any problems then. Oh, and that FFShowPixels link never worked for me either. Apparently I don't have permission to download the file.
-
Sorry to keep coming back with possible bugs. The following script claims that point 5,5 is not in the exclusion zones: #include "FastFind.au3" AutoItSetOption("WinTitleMatchMode", 4) $handle = WinActivate("[CLASS:Notepad]") FFSetWnd($handle) FFAddExcludedArea(0, 0, 10, 10) If FFIsExcluded(5, 5, $handle) Then MsgBox(0, "Exclusion", "5,5 is excluded!") Else MsgBox(0, "Exclusion", "5,5 is NOT excluded!") EndIfAm I using it incorrectly?
-
I think there's a problem with FFRemoveColor when there's more than one color in the list. The following script dies with a "program has stopped working" message from Windows: #include "FastFind.au3" FFAddColor(0x00FFFFFF) FFAddColor(0x00000000) FFRemoveColor(0x00FFFFFF)
-
Sorry to hear about your laptop, but it's good you have a recent backup. So many of my projects are not stored anywhere else. 2. You're right, the width of the black line is always equal to snapshot width modulo 4, so it disappears with FFSnapShot(0,0,299,150). However, the Pixel Aspect Ratio distortion remains, and I need to keep adjusting it if I open the image in Photoshop. 3. Ah, I didn't notice that. So to search a particular area of a snapshot I need to add exclusion zones everywhere else, or make a new snapshot of only the area I want? 4. Okay, but $Suffixe doesn't get used, so why bother fetching it? Unless the following code that sets $LastFileNameParam is supposed to be using it? I'll get started on some documentation this weekend. HTML will be better, so it can be bundled into a single .chm file with search/index/contents.
-
Update on the DllOpen failure. It's happening on both WinXP and Win7 32bit. I tried registering the DLL through Dependency Walker to get some more information and here's what came back: There's nothing in TRACER.TXT for these failed runs, so I don't know what else to look for. Would need some debugging in DllMain to figure it out. It's very odd that it only happens some of the time, though.
-
Hi FastFrench, Firstly, fantastic script! I'm still only testing, but I predict this is going to make my current project run at least 100 times faster. I have a few questions that have come up in my tests, though: 1. Every so often, when I run my script I get a message box saying "Can't start, try again." followed by the "Failed to load FastFind.dll, application probably won't properly work." message box from FastFind.au3. But if I wait a minute or two and try running again, it works fine. Do you have any idea what might be causing this? I thought that maybe the DLL is not being closed properly, but it does this sometimes even on the first execution. I'll continue investigating, because I won't be able to use your DLL if I can't fix it, and I REALLY, REALLY want to use your DLL! 2. FFSaveBMP produces some strange BMP files. I think someone mentioned it before, but there's always a black vertical line down the right hand side and when I try opening them in PhotoShop the Pixel Aspect Ratio is all messed up. FFSaveJPG used on the same SnapShot works okay. I can reproduce it with the following: #include "FastFind.au3" AutoItSetOption("WinTitleMatchMode", 4) $FFhWnd = WinGetHandle("[ACTIVE]") FFSetWnd($FFhWnd) FFSnapShot(0, 0, 300, 150) FFSaveBMP(@YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC, false) FFSaveJPG(@YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC, 100, false) 3. In my speed tests on FFNearestPixel, I noticed that changing the $Left, $Top, $Right and $Bottom parameters doesn't seem to do anything. Using these to restrict the search area does not increase the speed, and it continues to find pixel coordinates outside of the specified area. 4. In the FFSaveBMP and FFSaveJPG there is this line: local $Suffixe = DllCall($FFDllHandle, "int", "GetLastFileSuffix") Is this used for anything, or is it left over code? I'm willing to help with some documentation (in English) if you're still looking for someone. Keep up the good work!