measuring distance between two balls in millimeters - how to improve accuracy [closed]

asked 2013-05-04 13:18:09 -0600

efanucar gravatar image

updated 2013-05-04 13:24:34 -0600

Hi!

I'm currently learning OpenCV and my current task is to measure the distance between two balls which are lying on a plate. My next step is to compare several cameras and resolutions to get a feeling how important resolution, noise, distortion etc. is and how heavy these parameters affect the accuracy. If the community is interested in the results I'm happy to share the results when they are ready! The camera is placed above the plate using a wide-angle lens. The width and height of the plate (1500 x 700 mm) and the radius of the balls (40 mm) are known.

My steps so far:

  1. camera calibration
  2. undistorting the image (the distortion is high due to the wide-angle lens)
  3. findHomography: I use the corner points of the plate as input (4 points in pixels in the undistorted image) and the corner points in millimeters (starting with 0,0 in the lower left corner, up to 1500,700 in the upper right corner)
  4. using HoughCircles to find the balls in the undistorted image
  5. applying perspectiveTransform on the circle center points => circle center points now exist in millimeters
  6. calculation the distance of the two center points: d = sqrt((x1-x2)^2+(y1-y2)^2)

The results: an error of around 4 mm at a distance of 300 mm, an error of around 25 mm at a distance of 1000 mm But if I measure are rectangle which is printed on the plate the error is smaller than 0.2 mm, so I guess the calibration and undistortion is working good.

I thought about this and figured out three possible reasons:

  1. findHomography was applied to points lying directly on the plate whereas the center points of the balls should be measured in the equatorial height => how can I change the result of findHomography to change this, i.e. to "move" the plane? The radius in mm is known.
  2. the error increases with increasing distance of the ball to the optical center because the camera will not see the ball from the top, so the center point in the 2D projection of the image is not the same as in the 3D world - I will we projected further to the borders of the image. => are there any geometrical operations which I can apply on the found center to correct the value?
  3. during undistortion there's probably a loss of information, because I produce a new undistorted image and go back to pixel accuracy although I have many floating point values in the distortion matrix. Shall I search for the balls in the distorted image and tranform only the center points with the distortion matrix? But I don't know what's the code for this task.

I hope someone can help me to improve this and I hope this topic is interesting for other OpenCV-starters.

Thanks and best regards!

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-03 06:16:46.313753