PYTHON - How do I know if there is an object on the screen from a reference?

1

Basically I was wondering if there is a possibility of knowing if there is an object on the screen from a reference

Example: There is a generic program on the screen that displays a closed padlock, and when you do an action the padlock is displayed open, the python program recognizes the open padlock image and does an action when it happens. >

basically how to scan the screen looking for this open padlock, having an image as a reference, in the case I carry a small image with that padlock open, and when the program sees that the screen has the same thing as in the reference image it does an action!

resolution that I thought, take print from the screen every second, and compare if there is a piece of the same image as the reference image that I uploaded before, and if it does, it sounds like a trick, and the print taken would always have which overwrite the previous one to not have multiple prints)

I have already seen some things from OpenCv where it is possible to get an image with text and transfer the text of the image to a String, but could the process be verified in an image if there is another image?

What do I need to study?

    
asked by anonymous 08.02.2018 / 19:26

1 answer

1

I did something similar to days with the pyautogui library, following example:

import pyautogui

icon_pos = pyautogui.locateOnScreen('cadeado_aberto.png')

if icon_pos:
    print(icon_pos)
    print("Existe um cadeado aberto na tela")
else:
    print("Não existe nenhum cadeado aberto na tela")

Pyautogui Documentation

    
08.02.2018 / 19:45