Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check if a full screenshot has a particular image on it?

Previous research

Several years ago, when the "Diamond Dash" game was popular, I found a python script whose method to hit the diamonds blocks was something like this:

  1. Have images (jpg) of the individual diamonds.
  2. Get a screenshot of the whole screen (I had dual monitor so the script got a screenshot of the two screens and used this for the next step).
  3. Check if one of the individual diamonds images was present on the screen by doing something like an image check or comparison.
  4. If found, delimit a square area of ​​some other diamonds around this and check if there were some other similar diamonds by doing again what was done in step 3.
  5. If so, then move the mouse to the area where the first diamond was found and hit a left mouse click.

What I need

I have one automatic process which, after posting something on Facebook, takes a screenshot and sends this image via Telegram in order to notify the post in real time.

Every time you successfully post something, the image has a yellow strip with a legend with something like: "Your picture was successfully uploaded" or a different text, depending on the kind of post you made.

I need to check if the screenshot has that yellow strip. It has never changed in the past 5 years, so it will be useful in determining if the post was successful or not. If I know that, I can choose what to do next: send the confirmation via telegram if successful, or simply send a text informing that the post was unsuccessful.

I just need a way to find an image inside another image (the yellow strip in the full screenshot). It can be done in any language like php, python, or by using bash, or a tool like imagemagick or something else. The rest of the process I will do it on my own.

Your help is appreciated.

like image 760
Geppettvs D'Constanzo Avatar asked Nov 24 '25 20:11

Geppettvs D'Constanzo


1 Answers

There are most likely better ways to simply detect a yellow stripe and that facebook stuff can probably be solved using the facebook API.

But as you also asked for a general solution.

Finding a small image within a bigger images is called template matching. Google will overwhelm you with resources.

https://en.wikipedia.org/wiki/Template_matching might give start.

This should be comprised in any image processing tool-kit out there.

like image 120
Piglet Avatar answered Nov 28 '25 17:11

Piglet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!