2

Hey I am pretty new to python, but I am looking for a possibility to compare my running application with an image and check if this image is displayed in the running application. And if yes I want to get the coords of the matching position. Is that possible?

I think its something with PIL with imagegrab or something but I am not really sure if that will work as intended.

Reiming
  • 25
  • 1
  • 6

1 Answers1

1

Consider using PIL and openCV for this job.

from PIL import ImageGrab
pil_img = ImageGrab.grab()
opencv_img = numpy.array(pil_img)

then use OpenCV to process the image to find sub-image you are looking for. See these that does what you are looking for, but even allows the image to be rotated, scaled, etc.

http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html

http://docs.opencv.org/doc/tutorials/features2d/detection_of_planar_objects/detection_of_planar_objects.html

If you want to do this cross platform, then you will need to use wxWidgets to do the screengrab, see this

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35