EikoLoki / MICCAI_challenge_preprocess

MICCAI SCARED 2019 data challenge preprocessor
10 stars 7 forks source link

Regarding to the calculation of disparity from 3D scene points. #1

Open wtyuan96 opened 3 years ago

wtyuan96 commented 3 years ago

Thanks for your work. Recently I am reading your code, and I found a confusing implementation. Could you please help me out?

In your _depth_todisp.py file, here, you calculated disparity from 3D scene points( read from _scenepoints%.6d.tiff) using equation below:

d = fl bl / z p_x = fl x / z + cx p_y = fl * y / z + cy where the fl, bl, cx, cy are from Q which is calculated by _cv2.stereorectify.

The confusing point is that the 3D coordinate (x, y, z) is in the unrectified camera coordinate system, but the Q is in the rectified camera coordinate system. In other words, fl, bl, cx, cy are parameters for the rectified camera.

So in my opinion, the 3D coordinate (x, y, z) should be converted to rectified camera coordinate system using the R1 matrix which is a output matrix of _cv2.stereorectify function. And then, the converted 3D coordinate (x', y', z') can be used to calculate the disparity.

Looking forward to your reply.

wangyunlhr commented 2 years ago

Thanks for your work. Recently I am reading your code, and I found a confusing implementation. Could you please help me out?

In your _depth_todisp.py file, here, you calculated disparity from 3D scene points( read from _scenepoints%.6d.tiff) using equation below:

            d = fl * bl / z
            p_x = fl * x / z + cx
            p_y = fl * y / z + cy

where the fl, bl, cx, cy are from Q which is calculated by _cv2.stereorectify.

The confusing point is that the 3D coordinate (x, y, z) is in the unrectified camera coordinate system, but the Q is in the rectified camera coordinate system. In other words, fl, bl, cx, cy are parameters for the rectified camera.

So in my opinion, the 3D coordinate (x, y, z) should be converted to rectified camera coordinate system using the R1 matrix which is a output matrix of _cv2.stereorectify function. And then, the converted 3D coordinate (x', y', z') can be used to calculate the disparity.

Looking forward to your reply.

Sorry to disturb you. I don't fully understand the rectify process. So I just use this code to rectify. Have you checked whether your opinion is correct?And I have another question, this code is the pre-process for the video ,please ask whether the keyframe data (Initially image)needs the same processing. If needs, is it necessary to use endoscope_calibration.yaml and if M1 matrix is the camera parameters K or not.