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 boxes3d for points with negative depth #291

Closed
wants to merge 2 commits into from

Conversation

Aurelien-VB
Copy link
Contributor

This fixes issue #225, encountered when some points of boxes3d have negative depth (part of the object is behind the camera).

Points with negative depth are re-projected to positive depth by negating them. The line is then extend to outside the image to keep it coherent.

To extend the line, I compute the normalized vector from the linked point inside the frame to the point with negated depth (in image space). I then rescale the vector and add it to the negated point to extend outside the visible frame.

To find the right linked point, I take the furthest away from the point of negative depth. There is only 2 possible points since the third also has negative depth and thus there is no visible line that can can be seen from it.

The only limitation of this technique is if a point has negative depth and linked to two points in the visible image then one of the line will be distorted.

I also fix NaN when depth = 0.

Code to replicate results:

import numpy as np
from aloscene import Frame, BoundingBoxes3D, CameraExtrinsic, CameraIntrinsic

frame = Frame(np.zeros((3, 1000, 1000)))
intrisic = CameraIntrinsic(np.array([[500, 0.0, 500, 0.0], [0.0, 500, 500, 0.0], [0, 0, 1, 0]]))
extrinsic = CameraExtrinsic(np.array([[1, 0, 0, 0.062169], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]))
frame.append_cam_intrinsic(intrisic)
frame.append_cam_extrinsic(extrinsic)
box3d = BoundingBoxes3D([[-1, -1, 3, 1, 1, 10, 0], [1, 1, 3, 10, 1, 1, np.pi/3]])
frame.append_boxes3d(box3d)

frame.get_view([frame.boxes3d]).render()

@Data-Iab
Copy link
Collaborator

Data-Iab commented Jan 12, 2023

After the quick discussion, can you mark this PR as draft till you solve all its issues ? @Aurelien-VB

@Aurelien-VB Aurelien-VB marked this pull request as draft January 12, 2023 13:00
@Data-Iab
Copy link
Collaborator

feel free to re-open when you have time for it :))

@Data-Iab Data-Iab closed this Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alobugdays bug Something isn't working hard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BoundingBoxes3D don't render correctly when a part of it is outside the image
2 participants