Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rectify maps #18

Open
jprodriguezg opened this issue Mar 17, 2023 · 1 comment
Open

Rectify maps #18

jprodriguezg opened this issue Mar 17, 2023 · 1 comment

Comments

@jprodriguezg
Copy link

Hello, thanks for the cool dataset!

I am wondering how the maps to rectify distorted pixels were computed. I am trying to obtain the same results using cv2.fisheye.undistortPoints as suggested here. However, the results are different from those provided in $SEQUENCE_(left/right)_(x/y)_map.txt.

For instance, these are some results:

Pixels to rectify

[[[0. 0.]
[0. 1.]
[0. 2.]]]

Output from indoor_flying_left_(left/right)_(x/y)_map.txt

[[[-106.6652 -83.8143]
[-102.6674 -82.0455]
[ -98.7668 -80.3292]]]

Output from cv2.fisheye.undistortPoints

[[[-143.5242 -110.53386]
[-141.45755 -107.12762]
[-139.44424 -103.78565]]]

Could someone please explain how these maps were computed?

Thanks!

@vbrebion
Copy link

vbrebion commented Oct 3, 2023

Hi!

In case it might help anyone, here is how I was able to get the same values as the provided maps:

import cv2
import numpy as np
import yaml

with open("/path/to/camchain-imucam-indoor_flying.yaml", "r") as stream:
  yaml_data = yaml.safe_load(stream)
  davis_intrinsics = np.array(yaml_data["cam0"]["intrinsics"])
  davis_dist = np.array(yaml_data["cam0"]["distortion_coeffs"])
  davis_rect = np.array(yaml_data["cam0"]["rectification_matrix"])
  davis_proj = np.array(yaml_data["cam0"]["projection_matrix"])

K = np.array([[davis_intrinsics[0], 0, davis_intrinsics[2]],
              [0, davis_intrinsics[1], davis_intrinsics[3]],
              [0, 0, 1]])

pts_to_rectify = np.array([[[0., 0.],
                            [0., 1.],
                            [0., 2.]]])

rectified_pts = cv2.fisheye.undistortPoints(pts_to_rectify, K, davis_dist, None, davis_rect, davis_proj)
print(rectified_pts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants