I made a cascade with an opencv haar cascade , managed to scan certain objects on the screen, hover the mouse over them and click on them… But how can I move the mouse movement to the scanned thing closest to the mouse in a region that contains objects of multiple identical models. I mean this
my code :
def __init__(self, needle_img_path):
cv.ocl.setUseOpenCL(False)
if needle_img_path:
self.needle_img = cv.imread(needle_img_path)
self.needle_w = self.needle_img.shape[1]
self.needle_h = self.needle_img.shape[0]
def get_click_points(self, rectangles):
points = []
for (x, y, w, h) in rectangles:
center_x = x + int(w/2)
center_y = y + int(h/2)
points.append((center_x, center_y))
return points
def draw_rectangles(self, haystack_img, rectangles):
line_color = (255, 255, 255)
line_type = cv.LINE_8
for (x, y, w, h) in rectangles:
top_left = (x, y)
bottom_right = (x + w, y + h)
cv.rectangle(haystack_img, top_left, bottom_right, line_color, lineType=line_type)
return haystack_img