2

I am trying to use extrinsics function of matlab to calculate the translation vector. As a requirement i want to give the input camera parameters. i.e. Camera matrix, distortion matrix. But when i give the input i.e. camParam a 3x3 cameraMatrix, it gives me error.

camParam = [994.735326361544, 0, 624.663440953582;
            0, 998.166467837258, 364.087425569226;
            0, 0, 1]; 

    [rotationMatrix,translationVector] = extrinsics(left_right_eye_points,(face.model)',camParam);

I get the following error:

Error using extrinsics
Expected cameraParams to be one of these types:
cameraParameters
Instead its type was double.
Error in extrinsics>checkInputs (line 140)
validateattributes(cameraParams, {'cameraParameters'}, {}, ...
Error in extrinsics (line 91)
checkInputs(imagePoints, worldPoints, cameraParams);
Error in Simple_conversion_from_World_to_Camera_to_image (line 37)
[rotationMatrix,translationVector] = extrinsics(left_right_eye_points,(face.model)',camParam)

My question is:

1) how should i arrange my camParam, so that the function extrinsics may accept it.

2) In addition does it also need distortion coefficients? if yes than how to arrange that as well.

1 Answer 1

4

You have to do what the error message tells you to do. Create a cameraParameters object and use it. Probably you want cp=cameraParameters('IntrinsicMatrix',camParam)

The cameraParams object also allows you to set a distortion, the documentation explains the details.

5
  • 1
    You mean "cp = cameraParameters('IntrinsicMatrix',camParam)" thanks it worked.
    – khan
    Commented Aug 10, 2015 at 23:29
  • Yes, fixed my answer.
    – Daniel
    Commented Aug 11, 2015 at 0:00
  • yes. you gave me a hint/suggestion, and i further refined it :)
    – khan
    Commented Aug 11, 2015 at 5:11
  • 1
    @khan, when you create the cameraParameters object, keep in mind that it assumes 1-based pixel coordinates, meaning that the top-left pxiel's coordinates are [1,1]. Depending on where you got your intrinsics from, you may have to add 1 to the optical center. Also, try using the Camera Calibrator App: mathworks.com/help/vision/ug/single-camera-calibrator-app.html
    – Dima
    Commented Aug 11, 2015 at 13:26
  • @Dima intrinsic parameters are given with the dataset. Do you think above camParam is not correct.
    – khan
    Commented Aug 12, 2015 at 19:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.