Repository navigation
fix: allow a minimum disparity of zero in stereo_simple - #231
Merged
Merged
Conversation
stereo_simple shifted the right image with right_arr[:, :-drange[0]], which for a minimum disparity of 0 is right_arr[:, :-0], an empty slice, so any range starting at zero (drange=[0, 12], or an int, which becomes (0, n)) failed with a broadcast error. The slice now uses the width minus the minimum, which is right for zero as well. The xfail test that recorded the bug is replaced by tests of ranges starting at zero, one of which checks it agrees with a larger minimum. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
stereo_simple, stereo_BM and stereo_SGBM already accept a single integer n for drange, meaning (0, n), but it was in neither the signature nor the :type:. Add it to both, say what it means, and test it in stereo_simple. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Summary
Image.stereo_simple()failed for any disparity range that starts at zero, such asdrange=[0, 12]or(0, 12), withValueError: operands could not be broadcast together. It shifts the right image withright_arr[:, :-drange[0]], which for a minimum of 0 isright_arr[:, :-0], an empty slice. A minimum of zero is a legitimate range (zero disparity is a point at infinity), andstereo_BMandstereo_SGBMaccept it. The slice now usesright_arr.shape[1] - drange[0], which is right for zero as well.An integer
drange, which the code turns into(0, n), failed for the same reason and now works, as it already did instereo_BMandstereo_SGBM. It was in neither the signature nor the:type:of any of the three methods, so a second commit adds| intto all three and documents that an integernmeans(0, n).Found by the new stereo tests (PR 220), which recorded it as a strict
xfailtest. That test is replaced by tests of ranges starting at zero: the true disparity of a synthetic pair is recovered with a ZNCC of 1, and the result agrees with a range starting at 4, and an integer gives the same result as[0, n].Testing
tests/test_image_multiview.py: 19 passed and 1xfail, which belongs to a separate bug (the size of the outputs).mypyreports no issues. Not run: CI on Windows or OpenCV 4 (CI will).This change was written with AI assistance (Claude Code) and the diff has been read by the maintainer.
🤖 Generated with Claude Code