Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to create a matrix and make it a copy of the camera matrix?

Hello,

I have retrieved the calibration parameters for my camera, meaning that I have the camera matrix and the distortion vector. However, now that I have those, I want to undistort my image using the function:

Imgproc.undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distVector);

I have them all, I just don't know how to create a matrix and fill it with values.

I would like to do something like this:

Mat cameraMatrix = new Mat(3,3);
cameraMatrix.put(0, 0, f_x);
cameraMatrix.put(0, 1, 0);
cameraMatrix.put(0, 2, c_x);
cameraMatrix.put(1, 0, 0);
cameraMatrix.put(1, 1, f_y);
cameraMatrix.put(1, 2, c_y);
cameraMatrix.put(2, 0, 0);
cameraMatrix.put(2, 1, 0);
cameraMatrix.put(2, 2, 1)

Of course, I would do the same for the distortion vector.

The problem is that I haven't found any documentation on how to create matrices in OpenCV for Java. I don't mean like Mat mat = new Mat(), but how to create a matrix and fill it with values.

I hope that you guys can help.