Answer the question
In order to leave comments, you need to log in
What is the best way to get the color of a pixel?
I'm using getpixel to get the color, but the problem is that getting the color of a pixel doesn't always show the same result. (Colors differ) result (colors of squares from getpixel ) : original getpixel
r, g, b = screenshot_data.getpixel((center_x, center_y))
c = 0
for color in colors:
diff = 0
for i in range(3):
diff += abs(color[i]-pix[i])
if diff < 70:
return names[c]
c += 1
for key, value in images.items():
elem = pyautogui.locateOnScreen(value['path'], region=(x, y, x+CELL_SIZE, y+CELL_SIZE) )
if elem:
print('Meat found!', elem)
draw.rectangle([(s[0], s[1]),(s[0]+CELL_SIZE,s[1]+CELL_SIZE)], width = 1, fill=value['color'], outline='red')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question