1

I want to know how can I find these coordinates, which means how can I target a specific area on-screen so the program only searches for the given image in that area.

from python_imagesearch.imagesearch import imagesearch

pos = imagesearcharea("./github.png", 0, 0, 800, 600)
if pos[0] != -1:
    print("position : ", pos[0], pos[1])
else:
    print("image not found")

please see this image: screenshot

I want to target a specific area on my screen

j_4321
  • 15,431
  • 3
  • 34
  • 61
Owen Singh
  • 15
  • 7

1 Answers1

0

get your screen resolution (see this thread) and then you can at least work with percentages. Otherwise you have to hardcode some numbers.

Lucaash
  • 131
  • 1
  • 6
  • I still don't get how this is gonna help me – Owen Singh Aug 10 '20 at 13:21
  • 0,0 is upper left corner of the screen. First pair will be pixel coordinates of the upper left corner of your rectangle area, second pair bottom right corner of the selection rectangle area. Selection area is relative to your resolution so if you want to target specific position physically on the screen, you need to base it on the resolution. Otherwise it will slide left in larger resolutions or right on smaller ones. For your use case it looks like you are looking for 40%-50% of screen width and 5-15% of screen height. – Lucaash Aug 10 '20 at 13:28