Fix binding for cv::getRectSubPix#1368
Merged
Merged
Conversation
Member
|
Oops sorry @michaelarusso I missed the notification on this. Yes, it is breaking, but the original code was incorrect I see now. As such, merging now. Thanks you for the fix! |
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.
Updated the GetRectSubPix binding to use a float center (Point2f) end-to-end instead of integer coordinates, matching OpenCV’s API and intended behavior. The previous integer center lost precision at the boundary between Go and C++.
Why int casting defeats the purpose:
GetRectSubPix is specifically for sub-pixel sampling. Casting center coordinates to int truncates fractional values, so a center like (200.5, 172.5) becomes (200, 172). That removes sub-pixel precision and effectively turns the call into whole-pixel extraction, which defeats why this function exists.
Note:
This is a breaking API change: GetRectSubPix now accepts Point2f for center instead of image.Point. Existing clients must update call sites to pass Point2f values.