Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Grep - Xautomation #846

Open
1 task
ShellLM opened this issue Jul 25, 2024 · 1 comment
Open
1 task

Visual Grep - Xautomation #846

ShellLM opened this issue Jul 25, 2024 · 1 comment
Labels
Algorithms Sorting, Learning or Classifying. All algorithms go here. CLI-UX Command Line Interface user experience and best practices

Comments

@ShellLM
Copy link
Collaborator

ShellLM commented Jul 25, 2024

Visual Grep - Xautomation

Snippet

visual grep, greps for images in another image

Usage

visgrep [-hba] [-x x_off] [-y y_off]
        [-w x_off_width] [-h y_off_height]
        [-X start x_off] [-Y start y_off]
        [-d debuglevel] [-t tolerance] image.png detect.png match.png ...

  -h   This help
  -x   Set x offset for detection matching
  -y   Set y offset for detection matching
  -W   Set x offset width for detection matching
  -H   Set y offset height for detection matching
  -X   Start scanning at X
  -Y   Start scanning at Y
  -a   Scan all patterns, not just after matching the detection pattern
       note: this method is much slower because we scan for all images
             at every pixel instead of just at detection points.  Also,
             in this mode the detection image is ignored, there will be
             no matches for tile -1
  -t   Set tolerance for 'fuzzy' matches, higher numbers are more tolerant
  -b   Display 'badness' value, higher numbers mean match is less accurate,
       a badness value of 0 means the match is pixel-perfect

The detect.png and match.png can also be .pat files.

All .pat files are created using png2pat or rgb2pat.  The image.png is
scanned for detect.pat starting from X,Y specified above.  When detect.pat
is found, then all the match.pat files are scanned at an offset of x,y as
specified above.  If a match is found, then visgrep prints the x,y and
index of the item.

image.png must be an 8 bit deep RGB or RGBA png file.
For example, image.png is a screenshot and match1.pat .. to match5.pat are
images of letters a to e.  Each of these letters is enclosed in a blue box,
so detect.pat is an image of the upper left corner of the box.  This box is
not included in the match*.pat files, so they are actually offset 5 pixels
down and 4 pixels to the left.  You might run it like this then:

  visgrep -b -t50 -x-4 -y5 image.png match_corner.pat match_a.pat match_b.pat ...

Etc, with all matches listed.  Now suppose the screen showed 'ace' so
visgrep might output:

0 10,10 0
12 50,10 2 
7 90,10 4

Showing that match_a.pat (index 0) is at 10,10 on the screen.  If no match
is found even though the detection image is found, the index will be -1.

The first match was 100% accurate, while the second and third were very slightly
inaccurate, probably due to anti-aliasing on the fonts.

Exit status is 0 for successful match, 1 for no match, and 2 for error.

See the [examples page](http://hoopajoo.net/projects/xautomation.html) for use cases for different flags

Suggested labels

None

@ShellLM ShellLM added Algorithms Sorting, Learning or Classifying. All algorithms go here. CLI-UX Command Line Interface user experience and best practices labels Jul 25, 2024
@ShellLM
Copy link
Collaborator Author

ShellLM commented Jul 25, 2024

Related content

#3 similarity score: 0.89
#625 similarity score: 0.84
#134 similarity score: 0.83
#643 similarity score: 0.83
#845 similarity score: 0.82
#678 similarity score: 0.82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algorithms Sorting, Learning or Classifying. All algorithms go here. CLI-UX Command Line Interface user experience and best practices
Projects
None yet
Development

No branches or pull requests

1 participant