Change Read Only Properties to writable?

135 次查看(过去 30 天)
Using the vision toolbox for camera calibration you get the cameraParams out. These params are only read. How is it possible to do some changes in these params or a good way to by pass these limia
cameraParams=estimateCameraParameters(imagePoints, worldPoints)
Why I want to change it, I want to use a different radial and tangential distortion which I found in C+ with OpenCV and create a undistorted image and it's undistorted points.
  1 个评论
wei le
wei le 2018-3-7
编辑:wei le 2018-3-7
cameraParameters = vision.CameraParameters returns an object that contains the intrinsic, extrinsic, and lens distortion parameters of a camera. cameraParameters = vision.CameraParameters(Name,Value) configures the camera parameters object properties, specified as one or more Name,Value pair arguments. Unspecified properties use default values.

请先登录,再进行评论。

采纳的回答

Dima Lisin
Dima Lisin 2015-2-16
Hi Joep,
You can create another cameraParameters object using the constructor, and pass in all the parameters using name-value pairs. Fore example, let's say you have cameraParams1, and you want to replace its radial and tangential distortion coefficients. You can do the following:
cameraParams2 = cameraParameters('IntrinsicMatrix', ...
cameraParams1.IntrinsicMatrix, 'RadialDistortion', [0.2, -0.1], ...
'TangentialDistortion', [0.1, 0.1]);
Out of curiosity, what makes you think that the distortion coefficients you found using OpenCV are better?
  4 个评论
Joep
Joep 2015-2-17
编辑:Joep 2015-2-17
Ok thanks for your answer, seems to work fine I can use now other radial distortion coefficients and tangential. But to your comment about intrinsics. You said you need to add a camera center. But why exactly because I know that matlab uses 1-based indexing (0x00000001 to Ox00000004) instead of 0-based. Only difference that i see in the intrinsics matrix is the oritation.
Matlab:
intrinsics = [ax 0 0; gamma ay 0; u0 v0 1]
OpenCV:
intrinsics = [ax gamma u0; 0 ay v0; 0 0 1]
With: ax=fx*m, ay=fy*m, gamma is the skew which is zero in this case. v0 and u0 are the ideal center points.
A second question do you know the units of k1 k2 p1 p2? i saw somewhere it is in mm^-2, mm^-4, .... But i don't expect that because if you change the squaresize it does not change the k1 k2 ... so i rather be guessed it is in pixels or degrees (maybe degree/pixel).
Dima Lisin
Dima Lisin 2015-2-17
编辑:Dima Lisin 2015-2-17
Yes, the matrix is transposed, because of the different vector-matrix multiplication convention used by the MATLAB Computer Vision System toolbox. But also the pixel coordinates in OpenCV are off by 1, relative to those in MATLAB. In matlab the center of the top-left pixel of the image is (1,1). In OpenCV it is (0,0). That's why the optical center (u0, v0) will be one less in OpenCV.
I was wrong about the units of the distortion coefficients. They are, in fact, dimensionless. Please see my answer to your other question.

请先登录,再进行评论。

更多回答(1 个)

Joel David Berkson
Found a much better way to do this! Use the 'toStruct' function on the cameraparamets (this converts it to a normal struct that can be editted) then use the cameraParameters function to convert it back :-)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by