I am currently creating a PianoTiles AI, that has to locate all the black pixels from an ImageGrab. I have got all the positions of the Image Grab however I need to find out if there are black pixels in there and if so where they are so my AI can click them. Bellow I have put a snip-it of my code.
I have already had a look around the web but cant find anything. I think that the code goes something like this.
from PIL import ImageGrab, ImageOps
class Coordinates:
lines = [
(520, 300, 525, 760),
(630, 300, 635, 760),
(740, 300, 745, 760),
(850, 300, 855, 760)]
restartcheck = (660, 590, 725, 645)
restartbtn = (695, 615)
blackpixelpositions = []
def findtiles():
for line in Coordinates.lines:
i = ImageGrab.grab(line)
for pixel in i.getdata():
#if pixel is black
# x, y = pixel position
blackpixelpositions.append((x,y))
All I need is the above code to work and give me the black pixel positions.