Fix: depth unprojection #433
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed missing half-pixel shift in depth unprojection functions. The PR addresses #354.
Why was it missing?
Let's consider a 518 px x 518 px image, with height and width H, W = 518, and principal point coordinates cx, cy = W/2, H/2 = 259. In the image coordinate system (x, y with 0,0 in the top-left corner), pixel cords range from 0 to 517.
The current implementation does not perform the half-pixel shift, so after transforming to the u, v coordinate system (centered at the principal point) by subtracting cx, cy, the new pixel coordinates range from -259 to 258. That means the top-left corner has u, v = (-259, -259) and the bottom-right corner = (258, 258).
For a pinhole camera, these should be symmetrical around zero. As a result, the rays used for depth unprojection are slightly off, producing incorrect 3D points.
Performing the half-pixel shift is standard practice to correct u, v to a symmetric range from -258.5 to 258.5.