I have applied the object detection algorithm to detect the cow 4 teat. Now I want to find the centre point for a particular detected object as described in the below image in red colour dot.
Any suggestion or approach to do such things using OpenCV?
Thanks in advance for help!
You asked for suggestions, here is mine, a random one.
You already detected the object of interest, it’s oblong.
The black foreground makes it easy to get a binary image by using threshold, let’s start with Otsu threshold (it’s an automatic threshold level), then get contours of the object.
In this tutorial on contours properties:
look for “5. Orientation”. With the contour main orientation, loop on every vertex in the contour looking for the extremus in the main direction.
I hope it helps.
Thanks for replying to my answer…
With the contour main orientation, loop on every vertex in the contour looking for the extremus in the main direction.
Can you please explain this in details? If you are having any link or code snippet please! share it.
Thanks for the help!
Thanks for the reply! I will have a look on this.
Adrian Rosebrock at PyImageSearch has a fine example on finding extreme points in contours:
Keep in mind this example look for extremes on one edge at the time (x and y). You need to apply more elaborate math to find the extreme in one arbitrary direction.