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

  • Moderators
32 minutes ago, blue_screen said:

in 609. line program checks if  "result" an array or not in FFGetRawData. 

You have my sincere appreciation for the laugh this generated :D

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

ok I sent my script file, for example I can detect 3 yellow points number by using FFColorCount function but I only read X and Y values for one of my 3 points. How can I read 2. and 3. point location by using Fastfind.au3?

ss1.PNG

ss2.PNG

test.png

 

#include <MsgBoxConstants.au3>
#include "FastFind.au3"

Local $Color = 0xFFF200

sleep(5000)

$a1 = FFSnapShot()
$a2 = FFColorCount($Color)

MsgBox($MB_SYSTEMMODAL, "", "Detected Point Numbers: " & $a2[0])

$a3 = FFNearestPixel(0,0,$Color,False)
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "", "Detected Coordinates, X:" & $a3[0] & " Y:" & $a3[1])
EndIf

test.au3

Edited by Jos
Just insert the code into the post like this... Jos
Link to comment
Share on other sites

  • 3 weeks later...

On my phone atm.

If the function for color count also has coordinates then you just have to specify the right offset. (From your variable a2). I don't have the function code in front of me. I'm certain there was a function that gave a list of coordinates for all found pixels or groups.

What your doing is only searching for the nearest color from the point (0,0) and showing those coordinates. Which isn't really what you want. I'll look more when I get home.

 

Edit: So it appears the script doesn't have a function to return a list coordinates of found pixels. I was thinking of FFNearestSpot or FFBestSpot.

Maybe FastFrench can add a new function to return a list of all points that match criteria from FFNearestSpot and FFBestSpot.

But I think you can kind of get around this depending on the criteria you define. I think either of those two functions might work well. Depends how large / how many pixels of the same color are grouped together, that you define as spots to find.

But that doesn't really solve the problem.

It's not a good solution, but I was thinking to try searching through a nested loop for the X-Axis and Y-Axis. Like line scanning, while also using FFGetPixel. 

;;  Psudo code for finding a list of colors that match search color criteria.
;;
;; Create Snapshot 1
;;
;;  ;;This might speed up searching, keeping only the colors you want.
;; FFKeepColor($ColorToFind, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1)
;; FFKeepColor($yourColor, $Tolerance, False, 0,0,1920,1080, 1, -1)     ;;we're going to use the same snapshot to keep only your color
;;
;; ;;(optional) Perform FFColorCount() to get an idea of how many spots we need to find. This is probably not an exact count if the spots are larger than 1x1 pixels.
;;
;;  ;;this is an example for your screen size 1920x1080?
;;  For $j=0 to 1080 step $Y_stepSize           ;;If you change the step size > 1 then you can skip lines to increase speed, with the cost being accuracy of results.
;;      For $i=0 to 1920 step $X_stepSize       ;;
;;          $searchColor = FFGetPixel($i,$j)    ;;I think FFGetPixel returns an array, I could be wrong. Either way this should be the color to compare to.
;;          if $searchColor = $yourColor then
;;              ;;add result to an array list, with (x,y) coordinates from the current ($i,$j).
;;          EndIf
;;
;;          ;;(optional)
;;          ;;compare if the number of items in our array is greater than FFColorCount
;;          ;;if yes, determine if you want to ExitLoop. Again this might lead to count accuracy problems.
;;
;;      Next    ;;end X-Axis
;;  Next    ;;end Y-Axis
;;
;;  ;;Display your array list

That's the best I care to work on this at the moment. If I ever get around to it I would write it myself, because I could use this type of funciton as well.

 

Hope that helps at least. Sorry there's no better solution to finding a list of colors.

 

Edit: WiValdiBwrote some neater condensed code, however I feel that will run into problems if you are checking very small areas, such as 1x1 pixels or even up to 10x10 areas. This is because the exclusion function can only hold 1024 zones (rectangles) to exclude. When you have a monitor of 1920x1080, you can see that even checking one row or column of a 1x1 pixel will fail, because the limit is exceeded.

With the psudo code I wrote, you can limit your search range if you need to by changing the size limits. So instead of searching an entire desktop, lets say you search the area of the last snapshot coordinates. Basically you specify a box range, and count the number of pixels within that box. 

Edited by KrinnyAit
Explanation of function difference related to what WiValdiBB wrote.
Link to comment
Share on other sites

  • 3 weeks later...
On 17.08.2017 at 10:00 PM, blue_screen said:

ok I sent my script file, for example I can detect 3 yellow points number by using FFColorCount function but I only read X and Y values for one of my 3 points. How can I read 2. and 3. point location by using Fastfind.au3?

It should work for You
Of course You can modify that sample
Greets

 

#include <MsgBoxConstants.au3>
#include "FastFind.au3"

$Color = 0xFFF200

sleep(5000)

$a1 = FFSnapShot()
$a2 = FFColorCount($Color)

$PixelMax = 1000

MsgBox($MB_SYSTEMMODAL, "", "Detected Point Numbers: " & $a2)

For $PM = 1 to $PixelMax
$a3 = FFNearestPixel(0,0,$Color)
FFAddExcludedArea (0,0,$a3[0],$a3[1])
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "", "Detected Coordinates, X:" & $a3[0] & " Y:" & $a3[1])
 EndIf
Next

 

Edited by WiValdiBB
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...

To this day, I'm still trying to understand hot to properly replace PixelGetColor with FFGetPixel. For some mysterious reason they keep giving me different results.

Say, I want to know color of pixel(100,100). How do I do it in default autoit?

WinActivate("Window Name!")
Opt("PixelCoordMode",0)
Opt("MouseCoordMode",0)

$x = 100
$y = 100

$colour1 = Hex(PixelGetColor($x,$y))
MouseMove($x,$y)
MsgBox(64, "TEST", "Color = " & $colour1)

And how do I do it using FastFind? I am trying to do something like that

#include    "FastFind.au3"

WinActivate("Window Name!")
Opt("PixelCoordMode",0)
Opt("MouseCoordMode",0)

AutoItSetOption("WinTitleMatchMode", 4)

$FFhWnd = WinGetHandle("[ACTIVE]")
FFSetWnd($FFhWnd)
FFSnapShot(0,0,300,300)

$x = 100
$y = 100

$colour2 = Hex(FFGetPixel($x,$y))
MouseMove($x,$y)
MsgBox(64, "TEST", "Color = " & $colour2)

$colour1 will not be equal to $colour2. Or maybe it will. I can never guess. I have a feeling that using FastFind introduces some weird displacement, so pixel(0,0) isn't actually a top left pixel of my active window, like it should be.

Any help or ideas why is this happening?

Link to comment
Share on other sites

  • 2 months later...

So, I've been working on this for the last three days, and I've come to the conclusion that this library is incapable of overwriting a snapshot that has been used (Using either FFduplicate or simply calling FFsnapshot again.)

Running v2.2, this simple code will crash the SciTE compiler every single time.

#include "FastFind.au3"

#RequireAdmin
FFSetDebugMode(0)

ConsoleWrite(@CRLF & 'Starting program')
FFSetDefaultSnapShot(1)
FFSnapShot()
Sleep(2000)
FFSetDefaultSnapShot(2)
FFSnapShot()
If FFIsDifferent(1,2) Then
    ConsoleWrite(@CRLF & 'Yup, they"re different.' & @CRLF)
Else
    ConsoleWrite(@CRLF & 'Nope, they"re the same.' & @CRLF)
EndIf
FFSnapShot();This line will cause the program to crash.
;FFDuplicateSnapShot(1,2); This line would ALSO cause the program to crash.
ConsoleWrite(@CRLF & 'Finished replacing Snapshot 2')
ConsoleWrite(@CRLF & 'The green land of happiness that is forever out of reach..')

Perhaps the FF library is incompatible with Windows 10?

If so, does anyone have any alternative recommendations that can duplicate the functionality of FFLocalizeChanges (That is, a UDF that can find the pixel coordinates of the differences between two pixelchecksums or screenshots)?

Edit: This code appears to work fine on v2.1, but not v2.2.

To all future readers,

avoid v2.2!

Edited by Terrafire
Link to comment
Share on other sites

  • 1 month later...

Just wasted hours with this UDF to find out that the function FFColorCount doesnt work properly :(

If you use FFKeepColor on an image with a color code and shade variation you get the correct result.

But if you use FFColorCount on the same image with the same color code and shade variation the results are completely random.

I ended up using AutoIT embedded Pixelsearch which does the job very well!

Link to comment
Share on other sites

  • 5 months later...

Is there a way to disable the script from drawing on a window?

Every time I take a snapshot, it draws a box around the client Area of a window. I'm not sure if this is because I specify a window handle in my function calls.

This is problematic for me if I'm taking snapshots every 50ms or so,  I'd rather not have the screen flicker.

I don't know if I can specify this by modifying the DLL call, changing the debug mode, or if it's something entirely internal to the DLL.

 

Any help would be appreciated.

Found out it was a setting inside the FastFind.au3, need to disable debugger variable to 0x00.

Edited by KrinnyAit
Link to comment
Share on other sites

On 11/6/2017 at 11:42 PM, xeromycota said:

Is there any method to load bmp or jpeg file as snapshot?

I'd love a function like this myself. Sadly there isn't one.

 

However I think we can cheat a little. If you have an image in mind, you can probably load it (call it) from windows preview, make sure it's the full resolution (click the button if needed) and then taking a snapshot of that area. Now you have a snapshot of the image you wanted to load in the first place.

The other alternative is creating a blank snapshot, reading/loading the image to memory(variable), and using FFSetPixel to manually set the entire snapshot to the same as the image with a loop.

Link to comment
Share on other sites

  • 2 months later...

EDIT: I solved it by simply updating the version I was using

I've been trying this out now quite a lot using FFNearestSpot and while it does exactly what I want and it's really fast, it fairly often just stops running and/or I get an error message in french(...?) which I think uses a comedic line to say that something went wrong. Quite frustrating because it doesn't say what.PRlyr99.jpg

This is the main part of my script. I use ini reads for the values.
Is there anything in here you guys see that could be causing the script to close itself/get that french error message?
 

#include "FastFind.au3"
#include <MsgBoxConstants.au3>
#include <Misc.au3>

FFSetWnd ( "ITX Manager")
Opt("PixelCoordMode",2)

[bunch of inireads]

FFSetDebugMode ( 0 )
FFAddExcludedArea ( $crossx-$HitExclude, $crossy-$HitExclude, $crossx+$HitExclude, $crossy+$HitExclude
Local $hDLL = DllOpen("user32.dll")

while 1
    If _IsPressed("6f", $hDLL) Then
      FFSnapShot1()
         Local $aCoords = FFNearestSpot($Area , $PrioTag, $crossx, $crossy-$PrioTag, $HexColor, $ColVar, False)
         If Not @error Then
            $x1 = ($aCoords[0])
            $y1 = ($aCoords[1])
            $MoveX = ($x1-$crossx) / (10) * ($Xspeed)
            If $MoveX > $Deadzone Or $MoveX < -$Deadzone Then
               ;msgbox ($MB_OK, "okay", "hex" & $HexColor)
               _MouseMovePlus($MoveX, 0)
            EndIf
         ElseIf @error Then
            $MoveX = 0
         EndIf
      EndIf
 WEnd

Func FFSnapShot1()
   FFSnapShot($crossx-$FovLR, $crossy-$FovTop, $crossx+$FovLR, $crossy+$FovBottom)
EndFunc

Func Moves1()
   $x1 = ($aCoords[0])
   $y1 = ($aCoords[1])
   global $MoveX = ($x1-$crossx) / (10) * ($Xspeed)
EndFunc

Func _MouseMovePlus($X, $Y,$absolute = 0)
        global $MOUSEEVENTF_MOVE = 1
    Local $MOUSEEVENTF_ABSOLUTE = 32768
    DllCall("user32.dll", "none", "mouse_event", _
            "long",  $MOUSEEVENTF_MOVE + ($absolute*$MOUSEEVENTF_ABSOLUTE), _
            "long",  $X, _
            "long",  $Y, _
            "long",  0, _
        "long",  0)
EndFunc

I use it for automated administrative tasks at my engineering studies for examples of computer synchronization/automation.

The error happen usually when we get the mouse to catch on to the color we want and then we pull the mouse hard to the side forcing it to not find the color anymore. The script closes itself or we get the error message shown above. Please give your input what we can do to avoid this.

EDIT: I solved it by simply updating the version I was using

Edited by DigiBox
solved it myself
Link to comment
Share on other sites

  • Moderators

@YoloPota How, exactly, do you expect people to help you troubleshoot when you post no code?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 2 weeks later...

Hello, I'm using this to collect Data from live images in an infinite loop. As soon as I have collected the Data I no longer need to keep the image. I feel like this is too simple a problem I must have missed something. Is there a way I can manage snapshots infinitely, removing them as soon as I know I wont need them anymore? It would be ideal to remove them as soon as reasonable but my main issue is stack overflow, which I guess is reaching the limit. Thank You.

Link to comment
Share on other sites

  • 3 months later...
On 3/29/2018 at 9:52 PM, Terrafire said:

So, I've been working on this for the last three days, and I've come to the conclusion that this library is incapable of overwriting a snapshot that has been used (Using either FFduplicate or simply calling FFsnapshot again.)

Running v2.2, this simple code will crash the SciTE compiler every single time.

#include "FastFind.au3"

#RequireAdmin
FFSetDebugMode(0)

ConsoleWrite(@CRLF & 'Starting program')
FFSetDefaultSnapShot(1)
FFSnapShot()
Sleep(2000)
FFSetDefaultSnapShot(2)
FFSnapShot()
If FFIsDifferent(1,2) Then
    ConsoleWrite(@CRLF & 'Yup, they"re different.' & @CRLF)
Else
    ConsoleWrite(@CRLF & 'Nope, they"re the same.' & @CRLF)
EndIf
FFSnapShot();This line will cause the program to crash.
;FFDuplicateSnapShot(1,2); This line would ALSO cause the program to crash.
ConsoleWrite(@CRLF & 'Finished replacing Snapshot 2')
ConsoleWrite(@CRLF & 'The green land of happiness that is forever out of reach..')

Perhaps the FF library is incompatible with Windows 10?

If so, does anyone have any alternative recommendations that can duplicate the functionality of FFLocalizeChanges (That is, a UDF that can find the pixel coordinates of the differences between two pixelchecksums or screenshots)?

Edit: This code appears to work fine on v2.1, but not v2.2.

To all future readers,

avoid v2.2!

FFSnapShot() Should work also if the hwnd is hide (not minimized)?

Link to comment
Share on other sites

  • Developers

@zag8888,

It would help when you think before reporting a thread that's 8 years old!
I am not even going to explain any further how silly this is.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 months later...

Can someone help with an issue I've been getting recently? Using Versions 2.1.

Same issue as: 

 

Doesn't matter how I specify using #include "FastFind.au3", any script I use has 50/50 chance of the DLL and code not loading, resulting in the script exiting.

I can specify a direct path to FastFind.au3 or use a generic #include, which should point to the include directory at C:\Program Files (x86)\AutoIt3\Include.

Either way, both directories have the correct versions (2.1) and DLL files inside the directory.

Even with "FastFind.au3" in the same working directory as the script causes this issue.

 

When it doesn't fail, it works fine. :wacko:

I might try compiling a sample script and see if that helps, but I'd rather not use a compiled script every time I need to test something.

I'm using SciTE Version 4.1.0, and I assume the latest Autoit Version.

I'm unsure if there is a permission error for trying to access a resource unavailable to a user, but I have admin rights so that shouldn't be a problem.

 

This never used to be a problem, until I probably recently updated my autoit version and scite version.

--------------

I don't want to bump the thread again so I'll just edit my post. 

Has anyone used FastFind to convert the snapshot into something GDI+ can use? I haven't been able to correctly  assign a snapshot to a GDI+ Bitmap.

Nvm. Did it the hard way. Saved an snapshot to BMP and loaded the BMP to a GDI object. Takes an extra ~15ms to save and less than 1ms to load.

For those wondering, you cannot really use the FFGetRawData to pass into a GDI Object from Memory unless you jump through the hoops of formating the data into a .BMP file format, which was my mistake.

Unless someone can create a function for that and benchmark the numbers, it's much simpler to just save a BMP and load the BMP to a GDI object.

Edited by KrinnyAit
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...