Thanks for reply!
I analysed the topic I posted above once again and got some idea. Your code is simple, but it takes ~40s to execute. I've done this:
def search(screen, img):
sx, sy = screen.size
ix, iy = img.size
for xstart in range(sx - ix):
for ystart in range(sy - iy):
#search for the pixel on the screen that equals the pixel at img[0:0]
if img.getpixel((0,0)) == screen.getpixel((xstart, ystart)):
match = 1 #temporary
for x in range(ix): #check if first row of img is on this coords
if img.getpixel((x,0)) <> screen.getpixel((xstart+x, ystart)):
match = 0 #if there's any difference, exit the loop
break
if match == 1: #otherwise, if this coords matches the first row of img
for x in range(ix):
for y in range(iy):
#check every pixel of the img
if img.getpixel((x,y)) <> screen.getpixel((xstart+x, ystart+y)):
match = 0 #any difference - break
break
if match == 1: return (xstart, ystart) #return top-left corner coordinates
return (-1,-1) #or this, if not found
It uses getpixel method which is quite slow, but it executes in ~4s and I'm pretty glad of this. Thank you for targeting me!
Regards
mopsiok