Jump to content

A new image search solution


Lasker
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...

@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

Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
Share on other sites

  • 2 weeks later...

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??

Link to comment
Share on other sites

  • 1 month later...
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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

@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.?

"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 months later...

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

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

×
×
  • Create New...