Jump to content
Lasker

A new image search solution

Recommended Posts

Lasker

Hello,

Im a new AutoIt user, im from Spain and i would like to share here my own image search detection method.

What's about it?

It's not perfect, but with it you don't need to use any DLL file. You don't need to distribute the image file with your final AU3 Script, or Exe if compiled. The image size does not affect to the detection speed. It's bug free (i believe).

You can find here as an attach file, a distro package with all you need, and it includes a simple how-to guide.

Im going to paste here the how-to guide:

How to use this AutoIt image detector:

Point 1:

Install JRE (Java Runtime Environment), without this you can't execute Java Applications (.jar files). Open the Java tool named AISD with double click on it, or "java -jar aisd.jar" in the cmd. In AISD, open the image you want to detect in your script. Remember: the upper left pixel of the image, MUST be a not common color in the background if you want a fast detection. Then you will get a script file if you want, or only a clipboard copied version, full ready to paste into your main script because this one comes with extra help codes. Anyway, the generated code is the $sign definition of the image (calm down, point 3 explains what is the $sign and it's easy).

Point 2:

Paste the mentioned code in your main script, and try to follow the sample_usage script. If you know how to write au3 codes, it should be very easy. In general terms, all you need is to include image_search.au3, and then you can use the func image_search($sign, $width, $height). You need also the get_image_sign() function, that calculates the first parameter for image_search(). The get_image_sign() function is the one you have generated at point 1.

Point 3:

image_search() returns the center point of the target image. The func needs the $sign from the image, width and height. This $sign is the "footprint" of the image, in the form of an array of 9 integers. In most of the cases the $sign should be enough to identify the image, this is useful because using the $sign instead of the real image let you get a small script and a fast detection. You can also delete the image once you get the $sign. This $sign has always the same size (those 9 integers, it does not matter if the original image is small or big). How can you define the $sign for a certain image?, you don't need to generate the $sign, AISD does (point 1). Follow the sample_usage script and you will get it.

Files in this distro package:

* AISD.jar: The already explained Java app.

* image_search.au3: The library or module with the resources that lets you detect images.

* sample_usage.au3: The mentioned sample_usage script. It contains the smallest example, but i think it should be ok for learning purposes.

* sample_usage.exe: The sample_usage.au3 script compiled (au3 -> .exe). You can execute this to see the image_search() func working.

* sample_target.png: The image to be detected in the sample_usage. You can delete this file and the script will be fine.

* OffsetCalc.jar: It's only a Java tool to calculate the offset to transform an XY point into another one. It's useful if you want to use apply_offset function (from image_search.au3). Both things are only necessary when it's hard to find a version of the target image with upper left pixel in the way mentioned. As you can imagine, the idea is to detect another image and then apply the offset to get the real coordinates of the original target image.

Happy Detections

Lasker image_search.zip

Edited by Lasker
  • Like 2

Share this post


Link to post
Share on other sites
abdulrahmanok

Hi @Lasker Thank You very much for you sharing I tried it and found it very useful but why i cant detect another created "PNG" images I'm able to detect example image only !

 

Share this post


Link to post
Share on other sites
abdulrahmanok

Thank you very much it's working now I forgot to paste copied code ..

It's very easy to use thank you again for making Image search Easier but is this working in other Pc resolution ?

Share this post


Link to post
Share on other sites
lammaer25

@Lasker - just popped in to thank for sharing your solution. Well documented, easy to use and lightning fast. Good job mate!

Share this post


Link to post
Share on other sites
autog

@Lasker - thank you for this, I tested and it's clearly working.

Two questions please:

1. Does your image search support color variations? (e.g. imagesearch.au3 has smth like this - it can find image even if not perfectly same colors, maybe big image is from lower quality jpg etc).

2. Is it possible to find different sizes of the same image/pattern? This would be indeed great, imagesearch.au3 only solution is to have multiple target images.

I assume your 9 signs could be multiplied by the number of sizes to search, but not sure of speed then.

Thanks anyway

  • Like 1

Share this post


Link to post
Share on other sites
WiValdiBB

Hola :) Nice, going to test, I would like to have image search which can scale images, so no worry about browser zoom  or different screen resolutions :)
Also like autog ask, tolerance would be great :)
What about images with transparent parts, where part of image can be a bit different as they have ex animated background ?
Thx anyway, great idea and good job man, best greetings from Poland :)

Edited by WiValdiBB

Share this post


Link to post
Share on other sites
kemisten

Ok first of all it does not support dual screens. i used 2 screens with extrended view and it could not find the logo.I suspected it was because of 2 screens so i ddisconnected one and now it wiorks. But its kinda slow the image i used was a red button and it was a black background so I thought it would go faster if i had a red    pixel in the left uper corner but NO still slow..

 

 

Is it possible to scan an determined surface??

Share this post


Link to post
Share on other sites
knuxfighter

Is this checked by anyone for effectivity (greater than imagesearch library?) Thanks

Share this post


Link to post
Share on other sites
r4sc4l
On ‎18‎/‎05‎/‎2016 at 2:24 PM, Lasker said:

 

Can you direct me on where to do some research on methods to find "uncommon", or even better, "unique" pixel in an image sample? Thank you in advance.

Edited by Melba23
Huge quote removed

Share this post


Link to post
Share on other sites
Melba23

r4sc4l,

Welcome to the AutoIt forums.

But when you post in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - others know what they wrote and it just pads the thread unnecessarily.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
JLogan3o13

@dwaynek "It's broke" doesn't help anyone help you with your issue. How about a detailed explanation as to what you tried, and what is or is not working, including screenshots, error codes, etc.?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Hyflex

Hi,

I certainly can't get this working at all. I'm on Windows 10 and it throws up saying it failed to find the image.

I've tried it with the website open on every screen and I've also replaced the image with a fresh copy of the logo yet it still fails to find it... findBMP & ImageSearch both work just I want to try this one to see how much faster/slower it is and how resource intensive it is.

Edited by Hyflex

Share this post


Link to post
Share on other sites
BrewManNH
2 hours ago, Hyflex said:

findBMP & ImageSearch both work just I want to try this one to see how much faster/slower it is and how resource intensive it is.

If it doesn't work, then I guess it won't work for you to compare against, try something else or figure out why this one doesn't work.

No one is going to be able to help you because you've given absolutely zero information. Imagine you were trying to figure out how to help you with the total lack of information received, then you will realize what your post actually tells us.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hyflex
2 minutes ago, BrewManNH said:

If it doesn't work, then I guess it won't work for you to compare against, try something else or figure out why this one doesn't work.

No one is going to be able to help you because you've given absolutely zero information. Imagine you were trying to figure out how to help you with the total lack of information received, then you will realize what your post actually tells us.

How can I possibly give more information... I've told you everything... what else would you require?

I gave you my OS, I told you that I tried the example script, I told you that I tried the example script with a fresh image. I told you what didn't work / what the result was.

Share this post


Link to post
Share on other sites
BrewManNH

You told us, you're on Windows 10 and that it didn't find the image.

You said nothing about which script you used to find the image, or what error messages (if any) were returned. NOW you're telling us that you used the example script. Did you install the JRE?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hyflex
12 hours ago, BrewManNH said:

You told us, you're on Windows 10 and that it didn't find the image.

You said nothing about which script you used to find the image, or what error messages (if any) were returned. NOW you're telling us that you used the example script. Did you install the JRE?

I told you there error it throws...

15 hours ago, Hyflex said:

and it throws up saying it failed to find the image.

From this you can see that it has failed an if/else argument and that also tells you that JRE is installed otherwise it would have thrown an exception which also tells you that JRE is installed otherwise it would have thrown an exception.

I also told you that I double checked the images were correct by replacing the image with a new copy just incase it was unable to find due to having slighty different desktop resolution/brightness... etc.

I also told you that I am capable of using both findBMP & ImageSearch therefore I probably checked most of the basic reasons that it might be failing...

Share this post


Link to post
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

  • Similar Content

    • Xandy
      By Xandy
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.
      MapIt features Unity style dragable labels that adjust property values.

      MapParser is a C++ project that scans images for unique tiles.  MapParser is very fast.  Due to hard drive failure, many bugs were restored b/c I had to rewind many years.  Frustrated with the design, I wrote a new version from the ground up.  This New Version:  AutoIt Front-end, command line controls, and shared with the world; so that I can't lose it again.
      You can toggle the C++ MapParser off to see the difference in speeds between the MapParser CPP verse AutoIt function.  Function is named Scan_Tiles() in AutoIt.  You can also chose to download without MapParser.exe.
      At the moment Scanning a image resets the arrays, but you can add tiles after scanning.
      Images can be added as tiles without scan image at all.  Then configure settings to give your world parameters and manually fill the world data with tile indexes.
      Using the settings you can change tile size after a scan.  Example: you wanted to replace a map with different sized tiles.
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      Hotkeys, I use CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      Hotkeys are not saved to disk and thus are set to default between sessions.
      I might draw the world to pre-rendered surfaces and use them as multi-layer someday.  I do that in my AutoIt, DragonWarrior Remake but I could spend forever unsure what features are important for this.  The DW_Remake has a method of replacing a tile with a tile on two layers.  So you could replace a tree on the first layer with a grass, and a tree in the second layer.  This is all getting very confusing.
      I attempted to write the good code.  If something could be better, please advise.
      Forth release.  Enjoy.
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
      Special thanks: @AdmiralAlkex, @Melba23, @MrCreatoR
      Main AutoIt source file: Will not run without other Includes and SDL DLLs.
      Last Update: 5/23/2018 7:55 PM EST
      Next Version  
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
    • dadalt95
      By dadalt95
      Perform a simple google search!
      The script below works fine until fill the google form!
      What I can't find is how to submit the form, tried a couple of ways and none of them worked.

       
      #include <IE.au3> $oIE = _IECreate ("www.google.com") $o_form = _IEFormGetObjByName ($oIE, "f") $o_login = _IEFormElementGetObjByName ($o_form, "q") $username = "80251369" _IEFormElementSetValue ($o_login, $username) $o_numer = _IEGetObjByName($o_form, "btnK") _IEAction ($o_numer, "click")  
      The code runs without any problem.
      I don't know how to proceed!
      Thanks in advance!
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.