Factsheet
Using PIL (Python Image Library) to detect image on screen - Stack Overflow
Image recognition
image recognition in Python
How hard it is to make a OCR and a image recognition in Python?
What is the Best Image Processing Library for Python?
Is PIL the Python Imaging Library?
Is Python good for Image Processing?
Videos
I'm writing a script that requires me to figure out how many of an object are on the screen. The objects are kinda low resolution, think the ducks from Duck Hunt. I want to be able to track them in the screen and know their RGB value, even if acreen orientation changes.
However, I don't know much Python, let alone machine learning, so I'd like a library that has some capabilities built in.
I've tried pyautogui, but it doesn't always register the objects on screen, and I can't figure out how its confidence interval stuff works. I've heard of opencv, but it looks like it requires some machine learning knowledge.
Cheers.
PIL is the wrong tool for this job. Instead you should look into openCV (open source computer vision), which has fantastic python bindings. Here is a link to an example (in C but should be easy to redo with the python bindings) 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
Edit:
I assume you are using windows, as your example image looks like window. In this case you can use:
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.
If you want to do this cross platform, then you will need to use wxWidgets to do the screengrab: https://stackoverflow.com/a/10089645/455532
Even I wanted to do the same but using different module - pyautogui. I finally found the solution for my problem and I am sure this solution will also help you. You have to just go to this webpage and read the locate function topic completely and you'll be able to solve your problem.