Ask Your Question
0

Measuring Planar Objects with a Calibrated Camera

asked 2016-07-08 20:53:50 -0600

dimensional1 gravatar image

I would like to measure some coins placed on top of a calibration plate, as per this matlab example http://mathworks.com/help/vision/exam... .

Does OpenCV have an equivalent to the pointsToWorld function that lets you pass in pixel X,Y's and get world X,Y's on a plane?

edit retag flag offensive close merge delete

Comments

thanks but I don't see anything in those links directly relating to the question. Am I missing something?

dimensional1 gravatar imagedimensional1 ( 2016-07-09 05:46:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-22 01:31:25 -0600

dandur gravatar image

There's no analog for pointsToWorld as I know. You can find x and y (z is equal zero in such case) like this:

  1. apply cv::undistortPoints to your pixel coordintes (let's u and v) and get ideal coordinates (un and vn)
  2. solve system of linear equations:

    w * [un vn 1] = Rt * [x y 0 1]

that gets you

r11 * x + r12 * y - w * un = -t1;
r21 * x + r22 * y - w * vn = -t2;
r31 * x + r32 * y - w = -t3;

Here x and y are coordinates in chessboard plane, w is distant to point from camera, rij are components of rotation matrix and ti are components of translation vector.

edit flag offensive delete link more

Comments

Thanks, i'm still struggling to get the correct equation. My python to go from object points to image points looks like this:

object_points = np.array([[0, 0, .4], [.3, .2, .4]])

image_points, jacobian = cv2.projectPoints(object_points, rvec, tvec, camera_matrix, dist_coefs)

cv2.line(img, tuple(image_points[0].astype(int).ravel()), tuple(image_points[1].astype(int).ravel()),(0, 255, 0), 1)

image_points = np.array([[100, 100], [200, 200]])

object_points_on_plane = ????

but i'm unsure how to go back to object points on a plane from image points.

dimensional1 gravatar imagedimensional1 ( 2016-08-02 10:33:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-08 18:54:35 -0600

Seen: 1,603 times

Last updated: Jul 22 '16