Jump to content

Advanced Pixel Search Library


FastFrench
 Share

What do you think of this library ?  

35 members have voted

  1. 1. What do you think about FastFind ?

    • It's really great, I can't imagine doing a script without it
    • It's of some use for me in my current scripts
    • I could use it some day
    • Looks nice, but of no use for me
    • I've tried it, but it doesnt fit my needs
    • Sounds good on the paper, but can't make it work (bug or too difficult to use it)
  2. 2. Have you tried it ?

    • Yes, I'm using it right now
    • Somewhat, I've done some testing, will surely use it later
    • I've downloaded it and just played a little with packaged demo scripts
    • I've downloaded it, but not tried it so far
    • Not downloaded it so far, but I probably will some day
    • It's of no interested for me.
  3. 3. What is missing or should be improved ?

    • It has all the features I may need about Pixels Handling
    • OK it's pretty fast, but couldn't it be faster ?
    • Too hard to use it, could you simplify usage ?
    • Some additional features would be nice to have (please explain in a message)
    • It really lacks some decent documentation (I still hope to find someone to help on that)
    • Some critical features are missing, can't use it (please explain in a message)
    • I found some minor bugs (please explain in a message)
    • I've found some serious bugs (please explain in a message)
    • I've never tried it so far, can't tell
    • It would be nice if you could provide easy access to the associated tool - FFShowPixel
    • I would like to use it other languages. Could you provide wrappers ? (please explain in a message)


Recommended Posts

Y Could you give more informations please ? As you're giving 0,0,0,0 rectangle for the snapshot, it's full window. And as you never give any Window handle, you're presumaly working full screen. So I don't understand what you mean with "outside my area", where your area is the full screen... By the way, why do you use direct dllcall ? I suggest you experiment first with autoit wrapper functions, it would avoid some common errors and simplify the code. For instance, your first call to :$Basis_oben_links = DllCall($FFDllHandle, "int", "FFGetPixel", "int", 662, "int", 62, "int",$FFLastSnap) will fail, as you have no SnapShot done at that step. I've uploaded an fixed version 1.8

All my FFLastSnap are fullscreen with the DLLCall Method and it

was only a code snippet before. so i did forgett to put a DLLCall Lastsnap above that. , and i use the DLLCall method because it should be faster.Now i will try it without that.

main problem:

$Object2 = FFNearestSpot( 3 , 2, 359, 309, 0x4E5E63 , 1 ,false)
If IsArray($Object2) = True Then
  ;action

My understanding is that 359,309 is the spot (from fullscreen snapshot) and the 3 is the sizesearch (area) from the spot and the 2 is the maximal allowed founded numbers of the color. But sometimes for example, it finds the color outside the sizeseach area. and the function give me then a TRUE for more action . But that should be wrong in my context :graduated:

Edited by John81
Link to comment
Share on other sites

All my FFLastSnap are fullscreen with the DLLCall Method and it

was only a code snippet before. so i did forgett to put a DLLCall Lastsnap above that. , and i use the DLLCall method because it should be faster.

Now i will try it without that.

$Object2 = FFNearestSpot( 3 , 2, 359, 309, 0x4E5E63 , 1 ,false)
If IsArray($Object2) = True Then
  ;action

My understanding is that 359,309 is the spot (from fullscreen snapshot) and the 3 is the sizesearch (area) from the spot and the 2 is the maximal allowed founded numbers of the color. But sometimes for example, it finds the color outside the sizeseach area. and the function give me then a TRUE for more action . But that should be wrong in my context :graduated:

Hmmm... as stated in the comment in FastFind.au3:

; FFNearestSpot Function - This feature allows you to find, among all the area (or "spots") containing a minimum number of pixels
; a given color, the one that is closest to a reference point.
; Return Values: If unsuccessful, returns 0 and sets @Error.
; If successful, an array of 3 elements: [0] : X coordinate of the nearest spot   [1] : Y coordinate of the nearest spot   [2] : Number of pixels found in the nearest spot
; For example, suppose you want to detect a blue circle (Color = 0x000000FF) partially obscured, diameter 32 pixels (say with at least 45 pixels having the right color)
; and the closest possible to the position x = 198 and y = 543, in a full screen, so the function is called as follows:
; FFNearestSpot $Res = (32, 45, 198, 543, 0x000000FF)
; If Not @Error Then MsgBox (0, "Blue Circle", "The blue circle closest to the position 198, 543 is at "&$PosX&","[email="&$PosY&@LF"]&$PosY&@LF[/email]&" and contains "&$NbPixel&" blue pixels")
;
; Proto C function: int WINAPI GenericColorSearch(int SizeSearch, int &NbMatchMin, int &XRef, int &YRef, int ColorToFind, int ShadeVariation, int NoSnapShot)
Func FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1)

(359, 309) is the "reference point" (You can't define an area with only 2 numbers).

FFNearestSpot( 3 , 2, 359, 309, 0x4E5E63 , 1 ,false) will search a 3x3 square that contain at least 2 pixels with the color 0x4E5E63 (with +/-1 tolerancy on Red, Blue and Green components, as ShadeVariation is 1). If several such squares exist, then it will return the one that is the closest to the position x=359, Y=309.

Edited by FastFrench
Link to comment
Share on other sites

Hmmm... as stated in the comment in FastFind.au3:

; FFNearestSpot Function - This feature allows you to find, among all the area (or "spots") containing a minimum number of pixels
; a given color, the one that is closest to a reference point.
; Return Values: If unsuccessful, returns 0 and sets @Error.
; If successful, an array of 3 elements: [0] : X coordinate of the nearest spot   [1] : Y coordinate of the nearest spot   [2] : Number of pixels found in the nearest spot
; For example, suppose you want to detect a blue circle (Color = 0x000000FF) partially obscured, diameter 32 pixels (say with at least 45 pixels having the right color)
; and the closest possible to the position x = 198 and y = 543, in a full screen, so the function is called as follows:
; FFNearestSpot $Res = (32, 45, 198, 543, 0x000000FF)
; If Not @Error Then MsgBox (0, "Blue Circle", "The blue circle closest to the position 198, 543 is at "&$PosX&","[email="&$PosY&@LF"]&$PosY&@LF[/email]&" and contains "&$NbPixel&" blue pixels")
;
; Proto C function: int WINAPI GenericColorSearch(int SizeSearch, int &NbMatchMin, int &XRef, int &YRef, int ColorToFind, int ShadeVariation, int NoSnapShot)
Func FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1)

(359, 309) is the "reference point" (You can't define an area with only 2 numbers).

FFNearestSpot( 3 , 2, 359, 309, 0x4E5E63 , 1 ,false) will search a 3x3 square that contain at least 2 pixels this the color 0x4E5E63 (with +/-1 tolerancy on Red, Blue and Green components, as ShadeVariation is 1). If several such squares exist, then it will return the one that is the closest to the position x=359, Y=309.

I have to check three Graphics and every have his own specified charachteristic. previosly i checked and it did work in singular case, but when i use it in a while then it can´t realy to difer the graphics and after checking it with _arraydisplay its shows me he found my colors outside from sizsearch. The Solution is a fix array of 3 elements for TRUE now ,after i did found the FFNearestSpot coordinates ? Edited by John81
Link to comment
Share on other sites

You're right, I'll update the 1.8 version right now. Thanks.

Don't forget $DllName

You should change "FFAddExcludedArea" into "AddExcludedArea". Actually FFAddExcludedArea do not exist in the dll.

Problem solved! Thanks.

Odd. Will have to find some time to experiment that then. Can you tell if it works for JPG on the same computer where it fails for BMP ? As BMP is a very old and basic format, it would be surprising that this format is not supported on new OS...

Any additionnal hint is welcome.

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. :graduated: 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)
Link to comment
Share on other sites

All searches are done on the full SnapShot, except if you're using Exclusion rectangles. So in your case, fullScreen. So can't be "outside from sizsearch".

And i thought sizesearch is like Exclusion rectangles, so tell me pls what is the job from sizesearch ?
Link to comment
Share on other sites

OK, let see the attached bitmap.

If you're looking for black pixels (Farbe = 0x00000000), with the red point as a reference point, sizesearch = 4 and MinPixel = 3, then the blue and green spots meet the criteria. As the green is the closest from the reference point, this is the spot that will be returned as a result.

Alles klar ?

<P>post-63625-0-64720200-1319123005_thumb.p</P>

Link to comment
Share on other sites

@FastFrench

thx for the example.

But it does not good work with my Projekt. So i use my own heuristic with 2-3 FFGetPixel calls now .

My first project with Pixelsearch did need 0, 50 sec, now it needs only 0,12 sec.

Awesome , thx´s a lot :graduated:

Edited by John81
Link to comment
Share on other sites

Building on Newbie's script:

#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
FFResetExcludedAreas()
If FFIsExcluded(5, 5, $handle) Then
    MsgBox(0, "Exclusion", "5,5 is excluded!")
Else
    MsgBox(0, "Exclusion", "5,5 is NOT excluded!")
EndIf

I applied the AddExcludedArea fix so the first test works, but the second test that I added above says it is still excluded. Am I doing something wrong? I'm using 1.8.2.

Edited by PhilHibbs
Link to comment
Share on other sites

Grrr... you're right, there is a typo in FFResetExcludedAreas : return value should be "none" instead of "void" ("void" is the C wold, translated into "none" in AutoIt).

; Clears the list of all zones
;
; Proto C function: void WINAPI ResetExcludedAreas()
Func FFResetExcludedAreas()
    DllCall($FFDllHandle, "none", "ResetExcludedAreas")
EndFunc
Edited by FastFrench
Link to comment
Share on other sites

Hi FastFrench. I don't really have a bug report, but I thought I'd just mention that the 32-bit DLL needs XP SP2 or higher to run. You could mention that somewhere in your code to avoid worrying about any complaints about it not working, though it'd probably be wisest for people with XP to be up-to-date with their O/S.

The whole issue has to do with the new VC 2010 compiler's use of two API functions - EncodePointer and DecodePointer. There's an easy workaround for this in compiling for 32-bit code however. You can check this link if you'd like to add support for pre-SP2 XP. I use something similar in compiling C++ code (something I've just recently gotten back into).

Link to comment
Share on other sites

Thank you for this info. i wonder how many users of FastFind.dll are using pre-WinXP sp2 OS ? (or even Win2K I guess)

Well, next version will include the .asm code needed. Unfortunately, I don't have any computer old enough (and too lazy to make some virtual PC with old OS, just for this testing). Who could check if this fix would work ?

Edited by FastFrench
Link to comment
Share on other sites

I have a VM with XP on it, as well as Windows 2000. However, if you'd like to support Windows 2000 also, you'll need to override another API function - HeapSetInformation. That was added in some Win2000 service pack also, but if you'd like to cover all your bases, you can add that in. I'll save you the trouble of finding how to override that also - Here's the .ASM file (for use with FASM) I use to build the object file:

use32
format ms coff

section ".data" data
public __imp__EncodePointer@4
__imp__EncodePointer@4 dd dummy

public __imp__DecodePointer@4
__imp__DecodePointer@4 dd dummy

public __imp__HeapSetInformation@16
__imp__HeapSetInformation@16 dd dummy2


section ".text" code
dummy:
mov eax, [esp+4]
ret 4

dummy2:
mov eax, 1
ret 10h
Link to comment
Share on other sites

Nope, try it and use a Imports viewer (like the one in my signature) and you'll see just what dependencies the resulting DLL or executable has.

Here's another good link on it, which includes info on HeapSetInformation and setting the Linker Minimum System to 5.0.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...