How to use opencv camera_calibration.xlm parameters in ODM as cameras.json input

I have camera calibration values which have been estimated accurately in OpenCV format (OpenCV: Camera calibration With OpenCV) as f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2 and k_3. OpenCV outputs it in XML format like this example:

<cameraResolution>
800 500
</cameraResolution>
<camera_matrix type_id=“opencv-matrix”>
<rows>3</rows>
<cols>3</cols>
<dt>d</dt>
<data>
657.466979 0.0 319.500000
0.0 657.466979 239.500000
0.0 0.0 1.0
</data>
</camera_matrix>
<distortion_coefficients type_id=“opencv-matrix”>
<rows>5</rows>
<cols>1</cols>
<dt>d</dt>
<data>
-.41802 .50715 0. 0. -.57843
</data>
</distortion_coefficients>

<!–Extrinsic–>
<roll>90.0</roll>
<pitch>0.0</pitch>
<yaw>0.0</yaw>

I tried to transfer these values to a cameras.json file for use with ODM as listed below, but the processing fails and asks me to check for enough recognizable features and that the images are in focus. (well, they are in focus and have a ~30% overlap between images). Processing without the camera calibration input works, but the shape of the data is distorted (heavily curved).

{
" 800 500 brown 0.85": {
“projection_type”: “brown”,
“width”: 1336,
“height”: 890,
“focal_x”: 1849.024025,
“focal_y”: 1847.476235,
“c_x”: 994.899535,
“c_y”: 667.85276,
“k1”: 0.25294,
“k2”: 0.54536,
“p1”: -0.00204,
“p2”: -0.00178,
“k3”: 0.0
}
}

Obviously I tried to do what the error message asks, which was to increase the min-num-features. I doubled it from 10k to 20k, but still the same problem. I also tried to use the FLANN matcher, but same message.

I notice that the scale of the focal_x, focal_y, c_x and c_y values are completely different from the ODM-generated cameras.json (when I do not supply any camera calibration). ODM generates values on the 1e-1 scale, while my values are 1e4 scale. Are there different definitions for these values?

Also, what about the “extrinsic” values, do they play a role here?

Anyone encountered something like this, or have any ideas? Any help is much appreciated.

The last part of the log output:

2022-09-01 12:55:02,402 INFO: Matched 210 pairs (brown-brown: 210) in 21.39111846800006 seconds (0.10186247516666776 seconds/pair).
[INFO] running “/code/SuperBuild/install/bin/opensfm/bin/opensfm” create_tracks “/datasets/project/opensfm”
2022-09-01 12:55:04,052 INFO: reading features
2022-09-01 12:55:05,105 DEBUG: Merging features onto tracks
2022-09-01 12:55:05,329 DEBUG: Good tracks: 15611
[INFO] running “/code/SuperBuild/install/bin/opensfm/bin/opensfm” reconstruct “/datasets/project/opensfm”
2022-09-01 12:55:06,888 INFO: Starting incremental reconstruction
2022-09-01 12:55:08,473 INFO: 0 partial reconstructions in total.
[ERROR] The program could not process this dataset using the current settings. Check that the images have enough overlap, that there are enough recognizable features and that the images are in focus. You could also try to increase the --min-num-features parameter.The program will now exit.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.