How to find the true corner points of a binary object for robot object following purposes
Hi everyone,
I'm currently writing code for machine vision for real-time robot following using OpenCV. I have got to the point where I have a proper binary image from the raspberry pi to work with and have contour drawn using cv2.contours.
My problem lies with bounding box coordinates as they are not the true corners of the object I have. Fig1 shows the object normal to the camera. While fig2 shows the object facing in angle to right an fig3 to the left. I did some research and found that cv2.contours outputs x1,y1, width and height which might be the cause why I can't have true corners of the object.
I want this 4 corner points to give the robot the sense orientation relative to the object. My logic is :
- When the distance from lefttop_corner and leftbottom_corner isequal righttop_corner and rightbottom_corner
-------------> Then the robot is normal to object plane then move forward
- if distance from lefttop_corner and leftbottom_corner isgreater than lefttop_corner and leftbottom_corne
-------------> move the robot more to right
- if distance from lefttop_corner and leftbottom_corner isless than lefttop_corner and leftbottom_corne
-------------> move the robot more to left
is there someone who has done this similar project before? is this correct? Is there any way I can use cv2.contours to find true independent 4 corner points of my red square object? IF not please tell me other function that could solve my problem.
fig1
fig2 fig3
Thank you in Advance!
Try Aruco markers. They will make your life easier and provide 3D position and orientation of each marker with just a few lines of code.
If you insist on using your markers, have a look for playing card or business card detection on the internet.
I suggest attempt recognise road signs. It will work. I used opencv.
Btw, I used raspberry pi.
Witek, thanks for reply and suggestion! I will look into them!
Supra, can you provide me with some sort of example on your suggestion? Also im using raspberry pi to power my project and i need a solution that has pretty good response time thanks!
Here is link: Self drivinbg carsource code And the rest you have to do by yourself.