3

I have 4 coplanar points in object coordinates and the correspoinding image points (on image plane). I want to compute the relative translation and rotation of the object plane with respect to the camera.

FindExtrinsicCameraParams2 is supposed to be the solution. But I'm having troubles with using it. Errors keep on showing when compiling

Has anyone successfully used this function in OpenCV?? Could I have some comments or sample code to use this function??

Thank you!

TSL_
  • 2,049
  • 3
  • 34
  • 55
  • What kind of errors do you get? Can you post your code? – Sassa Aug 24 '12 at 05:25
  • Why don't you use findHomography()? – Jav_Rock Aug 24 '12 at 08:26
  • findHomography is not the desired solution since it solves for homography matrix/transformation between 2 sets of points whereas what I need is the rotation & transformation between points – TSL_ Aug 27 '12 at 07:00

3 Answers3

3

I would use the OpenCV function FindHomography() as it is simpler and you can converto easily from homography to extrinsic parameters.

You have to call the function like this

FindHomography(srcPoints, dstPoints, H, method, ransacReprojThreshold=3.0, status=None)

method is CV_RANSAC. If you pass more than 4 points, RANSAC will select the best 4-point set to satisfy the model.

You will get the homography in H, and if you want to convert it to extrinsic parameters you should do what I explain in this post.

Basically, the extrinsics matrix (Pose), has the first, second and fourth columns equal tp homography. The third column is redundant because it is the crossproduct of columns one and two.

Community
  • 1
  • 1
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
  • 1
    actually, the method you suggested is what I originally did since in my program, I already compute homography matrix beforehand and I just need to derive extrinsic params from homography matrix. I followed the computation of Zhang but failed. Now I have your code. It's very valuable to have a try. Thank you a lot! – TSL_ Aug 27 '12 at 07:06
1

After several days testing OpenCV functions related to 3D calibration, getting over all the errors, awkward output numbers, I finally get the correct outputs for these functions including findHomography, solvePnP (new version of FindExtrinsicCameraParams) and cvProjectPoints. Some of the tips have been discussed in use OpenCV cvProjectPoints2 function. These tips are also applied for the error in this post. Specifically, in this post, my violation is passing float data to CV_64F Mat. All done now!!

Community
  • 1
  • 1
TSL_
  • 2,049
  • 3
  • 34
  • 55
0

You can use CalibrateCamera2.

objectPts - your 4 coplanar points imagePts - your corresponding image points.

This method will compute instrinsic matrix and distortion coefficients, which tell you how the objectPts have been projected as the imagePts on to the camera's imaging plane.

There are no extrinsic parameters to compute here since you are using only 1 camera. If you used 2 cameras, then you are looking at computing Extrinsic Matrix using StereoCalibrate.

Ankur

Ankur
  • 46
  • 3