I'm working on a project that involves automatically clicking on objects in a video game as they appear on the screen. Naturally, each object has a distinct blue outline - so I've isolated all colors from the image except for that blue color.
The image below shows an example of a pre-processed screenshot of the game. Using OpenCV in Python, how can I:
- Get the position of the center-most pixel of each object?
- Get the position of the top-most pixel of each object?
E.g.,
CodePudding user response:
You can use a relatively less-known cv2
method
Output image:
The variable names explain the code pretty well already, after all, Python is similar to plain English!