render_depthmap_example icon indicating copy to clipboard operation
render_depthmap_example copied to clipboard

The camera intrinsic [cx] and [cy] is useless in this demo.

Open qpc001 opened this issue 3 years ago • 8 comments

The camera intrinsic [cx] and [cy] is useless in this demo.

qpc001 avatar Apr 26 '22 13:04 qpc001

It is used in the intrinsic, see the K matrix in this function, for instance: https://github.com/pablospe/render_depthmap_example/blob/dbd53b33ae13a78514b8307416bd7d4651d38cb5/visualization.py#L133

Or what do you mean exactly?

pablospe avatar Apr 27 '22 14:04 pablospe

它用于内在函数,参见此函数中的 K 矩阵,例如:

https://github.com/pablospe/render_depthmap_example/blob/dbd53b33ae13a78514b8307416bd7d4651d38cb5/visualization.py#L133

或者你到底是什么意思?

I mean , the (.capture_depth) or (capture_screen) is still using the intrinsic [ width, height, fx, fy , width/2 , height/2], not the [ width, height, fx, fy , cx , cy].

Here is the same issue : [https://github.com/isl-org/Open3D/issues/3079]

qpc001 avatar Apr 28 '22 05:04 qpc001

Do you mean this: https://github.com/pablospe/Open3D/blob/0728214089c2f149e522b3b81006067753a899ad/cpp/open3d/visualization/visualizer/ViewControl.cpp#L172-L173 ?

    intrinsic.intrinsic_matrix_(0, 2) = (double)window_width_ / 2.0 - 0.5;
    intrinsic.intrinsic_matrix_(1, 2) = (double)window_height_ / 2.0 - 0.5;

pablospe avatar May 02 '22 04:05 pablospe

I mean the following code block:

https://github.com/pablospe/Open3D/blob/0728214089c2f149e522b3b81006067753a899ad/cpp/open3d/visualization/visualizer/ViewControl.cpp#L196

if (!allow_arbitrary && (window_height_ <= 0 || window_width_ <= 0 ||
                             window_height_ != intrinsic.height_ ||
                             window_width_ != intrinsic.width_ ||
                             intrinsic.intrinsic_matrix_(0, 2) !=
                                     (double)window_width_ / 2.0 - 0.5 ||
                             intrinsic.intrinsic_matrix_(1, 2) !=
                                     (double)window_height_ / 2.0 - 0.5)) {
        utility::LogWarning(
                "[ViewControl] ConvertFromPinholeCameraParameters() failed "
                "because window height and width do not match.");
        return false;
    }

the flag "allow_arbitrary" doesn't change the camera intrinsic value about "cx" and "cy". As a result, the function (.capture_depth) 或 (capture_screen) is still using the intrinsic [ width, height, fx, fy , width/2 , height/2].

qpc001 avatar May 02 '22 18:05 qpc001

Hi @pablospe ! I met with the same problem.

If I change the cx or cy of intrinsic_matrix in view_point.json, the rendered image doesn't change with cx or cy. Logically, when I increase cx, the rendered image should shift to the right by the according pixel distance. However, the open3D returned the same images with different cx.

It means that the visualizer of open3D still uses the intrinsic [ width, height, fx, fy , width/2 , height/2] instead of [ width, height, fx, fy , cx , cy] that I specify.

Rashfu avatar Nov 08 '23 15:11 Rashfu

One would need to debug the Open3D viewer to find the problem and see where is set to width/2 , height/2.

I had some problems with Open3D viewer so I tried to replicate this code using pyvista (VTK backend), in this branch: https://github.com/pablospe/render_depthmap_example/tree/pyvista Maybe you want to give a try to this branch to avoid flighting with Open3D viewer.

pablospe avatar Nov 09 '23 13:11 pablospe

Another alternative: https://github.com/cvg/raybender (see the demo: https://github.com/cvg/raybender/blob/main/examples/demo.py)

pablospe avatar Nov 09 '23 13:11 pablospe

Thank you for your prompt response. I will give it a try ! :smiley:

Rashfu avatar Nov 09 '23 13:11 Rashfu