How to find the true corner points of a binary object for robot object following purposes

asked 2019-09-24 08:04:31 -0600

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 :

  1. 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

  1. if distance from lefttop_corner and leftbottom_corner isgreater than lefttop_corner and leftbottom_corne

-------------> move the robot more to right

  1. 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 image description

fig2 image description fig3 image description

Thank you in Advance!

edit retag flag offensive close merge delete

Comments

1

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.

Witek gravatar imageWitek ( 2019-09-24 08:31:57 -0600 )edit

I suggest attempt recognise road signs. It will work. I used opencv.

supra56 gravatar imagesupra56 ( 2019-09-25 05:19:01 -0600 )edit

Btw, I used raspberry pi.

supra56 gravatar imagesupra56 ( 2019-09-25 05:20:55 -0600 )edit

Witek, thanks for reply and suggestion! I will look into them!

bartley gravatar imagebartley ( 2019-09-25 09:30:56 -0600 )edit

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!

bartley gravatar imagebartley ( 2019-09-25 09:32:44 -0600 )edit

Here is link: Self drivinbg carsource code And the rest you have to do by yourself.

supra56 gravatar imagesupra56 ( 2019-09-25 20:26:24 -0600 )edit