openMVS icon indicating copy to clipboard operation
openMVS copied to clipboard

error of image center position or image scale

Open flashlau opened this issue 1 year ago • 5 comments

I have images, pointclouds and camera trajectory. Then I generate a mvs file by calling "interface.h". But all image center points (green) do not at the center of their rectangle region. Screenshot from 2024-01-11 13-42-21

I only have one camera. So I set camera.K = intrinsic_mat; camera.R = Interface::Mat33d::eye(); camera.C = Interface::Pos3d(0, 0, 0); then I set N poses for N images as follows: pose.R = R; pose.C = -R.t()*t; where R and t are from transformation matrix (4x4, from World coordinate to Camera coordinate) The camera trajectory and pointcloud in Viewer looks good, but the image center or image scale must be wrong. I cannot find the bug. Did I make a mistake at any step or miss any parameter?"

flashlau avatar Jan 11 '24 06:01 flashlau

Do you set the image resolution in the one camera you initialized?

Are you sure you set the pose correctly? Inn the screenshot i see only the cameras and not the point cloud.

cdcseacave avatar Jan 11 '24 13:01 cdcseacave

I hide the point-cloud in Viewer in order to see the green points clearly. And yes, I set camera.width = img_w; camera.height = img_h; double fScale = (double)1 / double(max(img_w, img_h)); but fx, fy, cx, cy in camera.K are all divided by fScale. So width and height parameter are optional when K is normalized (as mentioned in "Interface.h") I enable the visualization for point-cloud now. the cloud and camera poses looks correct. But all image centers are wrong. (Or the image center is correct but the scale of image(view) is wrong. I don't know.) Screenshot from 2024-01-12 09-24-07

flashlau avatar Jan 12 '24 01:01 flashlau

no need to normalize if you set the width and h, pls try that

cdcseacave avatar Jan 12 '24 03:01 cdcseacave

I comment the normalization part and remain camera.width, camera.height and camera.K. then re-generate mvs file. in Viewer, (we hide point cloud) Screenshot from 2024-01-12 11-37-39 it looks camera's size become 0

flashlau avatar Jan 12 '24 03:01 flashlau

Strange. You can put a break point where the MVS scene you generate is read, and check that you get the values you expect.

cdcseacave avatar Jan 12 '24 04:01 cdcseacave

Strange. You can put a break point where the MVS scene you generate is read, and check that you get the values you expect.

@cdcseacave in this line :
if (!scene.Load(fileName, true))

I found camera.K(0,2) and camera.K(1,2) in "scene.images._vector.camera.K.val" is NOT equal to that of "scene.platforms._vector.cameras._vector.K.val", i.e. principal point value, why?

flashlau avatar Feb 28 '24 09:02 flashlau

depends, is K in platforms normalized? do you change the resolution? simplest set K in platforms not normalized, set width and height too, and use the same resolution when u use it

cdcseacave avatar Feb 28 '24 18:02 cdcseacave

no need to normalize if you set the width and h, pls try that

I found that it's caused by normalization of K. No need to normalize K.

flashlau avatar Mar 01 '24 02:03 flashlau

Strange. You can put a break point where the MVS scene you generate is read, and check that you get the values you expect.

This bug is caused by my fault. I called "ARCHIVE::SerializeSave" but set the "version" parameter to 0 which stop the serialization of camera size. Just remove it to use the default value.

flashlau avatar Mar 01 '24 02:03 flashlau

depends, is K in platforms normalized? do you change the resolution? simplest set K in platforms not normalized, set width and height too, and use the same resolution when u use it

Many thanks for your help! @cdcseacave

flashlau avatar Mar 01 '24 02:03 flashlau