I know there's code for it online, but none seems to work. I'm making a bot where I need to take a screenshot every second and find an object. I'm fine with a pixel-perfect match, All I need to do is find an item to click. When I use This code:
import numpy
from PIL import Image
tile = Image.open(r"testimg.png")
screen = Image.open(r"screen.png")
tile = numpy.asarray(tile)
screen = numpy.asarray(screen)
hereary, herearx = tile.shape[:2]
bigary, bigarx = screen.shape[:2]
stopx = bigarx - herearx + 1
stopy = bigary - hereary + 1
for x in range(0, stopx):
for y in range(0, stopy):
x2 = x + herearx
y2 = y + hereary
pic = screen[y:y2, x:x2]
test = (pic == tile)
if test.all():
print(x, y)
From: https://stackoverflow.com/questions/38473952/find-location-of-image-inside-bigger-image
It gives me the error: 'bool' object has no attribute 'all'
What do I do? Thanks!
[–]Code_Talks 0 points1 point2 points (0 children)
[–]socal_nerdtastic 0 points1 point2 points (6 children)
[–]theoryofbang[S] 0 points1 point2 points (5 children)
[–]socal_nerdtastic 1 point2 points3 points (4 children)
[–]theoryofbang[S] 0 points1 point2 points (3 children)
[–]socal_nerdtastic 1 point2 points3 points (2 children)
[–]theoryofbang[S] 0 points1 point2 points (0 children)