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

Fix calibration.project_to_image #187

Merged
merged 3 commits into from
Sep 4, 2024
Merged

Fix calibration.project_to_image #187

merged 3 commits into from
Sep 4, 2024

Conversation

pascalzauberzeug
Copy link
Contributor

@pascalzauberzeug pascalzauberzeug commented Sep 3, 2024

While creating a calibration, I found that the zero-function of rosys.geometry.Rotation uses integers, which causes cv2.Rodrigues to fail, because it expects floats.
While using .astype(np.float32) helps, using floats directly makes it easier to use in the future.

import cv2
import numpy as np
from rosys.geometry import Pose3d, Rotation

# works
extrinsics = Pose3d(x=0, y=0, z=0, rotation=Rotation(R=[[0, 0, 0], [0, 1, 0], [0, 0, 1]]))
R = extrinsics.rotation.matrix.astype(np.float32)
Rod = cv2.Rodrigues(R.T)[0]

# works
extrinsics = Pose3d(x=0.0, y=0.0, z=0.0, rotation=Rotation(R=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))
R = extrinsics.rotation.matrix
Rod = cv2.Rodrigues(R.T)[0]

# doesn't work without the changes
extrinsics = Pose3d(x=0, y=0, z=0, rotation=Rotation(R=[[0, 0, 0], [0, 1, 0], [0, 0, 1]]))
R = extrinsics.rotation.matrix
Rod = cv2.Rodrigues(R.T)[0]

edit: float64 is needed for our tests

@pascalzauberzeug pascalzauberzeug added the bug Something isn't working label Sep 3, 2024
@pascalzauberzeug pascalzauberzeug added this to the 0.16.0 milestone Sep 3, 2024
@pascalzauberzeug pascalzauberzeug marked this pull request as draft September 3, 2024 17:13
@pascalzauberzeug pascalzauberzeug marked this pull request as ready for review September 3, 2024 17:41
@falkoschindler falkoschindler merged commit ee2bc45 into main Sep 4, 2024
5 checks passed
@falkoschindler falkoschindler deleted the fix_rotation_zero branch September 4, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants