Python Forum
Button Press When Pixel Color Changes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button Press When Pixel Color Changes
#1
I am new to scripting with python and I just need some help with something that is simple.
All I need to do is a button press or mouse click whenever a pixel is a certain color.
Ex. if pixel 960,540 is any value of blue, press spacebar or
if pixel 960,540 is a value yellow, click at 0,0

I already have code that feeds a live stream of one quarter of my screen:

import cv2
import numpy as np
import time
from PIL import ImageGrab


last_time = time.time ()
while(True):
        screen = np.array(ImageGrab.grab(bbox=(0,540, 960, 1080)))
        #printscreen_numpy =  np.array(printscreen_pil.getdata(),dtype='uint8')

        print('Loop took {} seconds'.format(time.time()-last_time))
        last_time = time.time()
        cv2.imshow('window', cv2.cvtColor(screen, cv2.COLOR_BGR2RGB))
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break
Just need help or be given any sources that can help me. Thanks in advanced.
Reply


Messages In This Thread
Button Press When Pixel Color Changes - by bak989 - Apr-22-2018, 04:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Change color pixel in an image louloudevinci 2 39,197 Mar-25-2018, 08:27 PM
Last Post: louloudevinci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020