Ask Your Question
0

Measuring Planar Objects with a Calibrated Camera

asked Jul 9 '16

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?

Preview: (hide)

Comments

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

dimensional1 gravatar imagedimensional1 (Jul 9 '16)edit

1 answer

Sort by » oldest newest most voted
0

answered Jul 22 '16

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.

Preview: (hide)

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 (Aug 2 '16)edit

Question Tools

1 follower

Stats

Asked: Jul 9 '16

Seen: 1,738 times

Last updated: Jul 22 '16