fix: Fix coordinate system conversions#3918
Open
JimPatterson wants to merge 1 commit into
Open
Conversation
This was coded by an AI agent. It said: `convertFramePointToCameraPoint` and `convertCameraPointToFramePoint` on Android were using `sensorToBufferTransformMatrix` directly without accounting for the frame's orientation. That matrix handles sensor crop/zoom but carries no rotation — rotation is separate metadata in `rotationDegrees`. As a result, passing oriented-space coordinates (as returned by ML analyzers) produced silently wrong camera coordinates for any non-upright frame. The fix mirrors iOS's `FrameCoordinateSystemConverter`: before applying the inverted sensor matrix, un-rotate the input point from oriented space to raw buffer space; when converting the other direction, apply the forward rotation to the buffer-space result. The same fix is applied to `HybridDepthFrame`. The two coordinate harness tests are updated to match the corrected API: - The round-trip test now passes the oriented-space center `(h/2, w/2)` for rotated frames rather than the raw buffer center `(w/2, h/2)`, since `convertFramePointToCameraPoint` now expects oriented coordinates. - The oriented-rectangle test is redesigned as a true round-trip check (oriented → camera → oriented) instead of comparing two paths that diverge after the API change.
|
Someone is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This addresses the android side of #3871. This has been tested on a real android device using the code in #3878 and it works correctly for all orientations. But I don't have a mac or an iPhone and can't test iOS.
This was coded by an AI agent. It said:
convertFramePointToCameraPointandconvertCameraPointToFramePointon Android were usingsensorToBufferTransformMatrixdirectly without accounting for the frame's orientation. That matrix handles sensor crop/zoom but carries no rotation — rotation is separate metadata inrotationDegrees. As a result, passing oriented-space coordinates (as returned by ML analyzers) produced silently wrong camera coordinates for any non-upright frame.The fix mirrors iOS's
FrameCoordinateSystemConverter: before applying the inverted sensor matrix, un-rotate the input point from oriented space to raw buffer space; when converting the other direction, apply the forward rotation to the buffer-space result. The same fix is applied toHybridDepthFrame.The two coordinate harness tests are updated to match the corrected API:
(h/2, w/2)for rotated frames rather than the raw buffer center(w/2, h/2), sinceconvertFramePointToCameraPointnow expects oriented coordinates.