I am trying to figure out a good method to detect the red border in this game with python and struggling getting alot of false positives or missing it completely with my current method. I am currently using open cv and just performing some template matching with small screenshots of the red border. Anyone have any ideas of how to better find this border in this image and see the actual boundries? Full resolution PNG here: https://ibb.co/FB0MkBh JPEG here: Code snippet: # Define redborder image paths redborder_image_paths = [ 'bottomLeftBorder.png', 'bottomRightBorder.png', #'topLeftBorder.png', 'topRightBorder.png', 'topRightMaxBorder.png', 'topLeftBorderMaxZoom.png', 'topleftMaxZoom.png', 'bottomLeftMaxZoom.png', 'topRightBorderMaxZoom.png', 'topRightBorderGreenMap.png', 'bottomRightBorderGreenMap.png', 'topRightBorderOutBoundMaxZoom.png', 'bottomLeftBorderMaxZoomOutBound.png', 'topleftbordermaxZoomhole.png', ] # Calculate the distances from the townhall image to each found redborder image for border_index, border_gray in enumerate(redborder_images_gray): result_border = cv2.matchTemplate(screenshot_gray, border_gray, cv2.TM_CCOEFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(result_border) print(f"Border Image caculating.. ({redborder_image_paths[border_index]}): Confidence: {max_val}") Tried using open CV and not getting great results its definitely sometimes working but often times it finds false positives with high confidence above 8.0 or misses some close borders that it should be able to detect. I am using openCV to detect certain structures in the image with great results it's mostly this red border line that i'm struggling with. I would only assume there some better logic to detect that I am just too noob to know. Continue reading...