mirror of
https://github.com/opencv/opencv.git
synced 2026-11-19 07:45:26 -06:00
features2d: fix BRISK on sub-matrix images - #30831 `BRISK_Impl::smoothedIntensity()` indexes the image with its width as the row stride in the direct-pixel paths. For an image that is a region of a larger one (`img(roi)`) the row step differs from the width, so those samples were read from the wrong rows. `detect()`/`compute()` on such an image returned wrong keypoint angles (the orientation uses these samples) and wrong descriptor bytes (maximum byte difference 255), and both depended on the pixels around the region. The function now uses `image.step`; the integral image is a fresh continuous matrix and is unchanged. Proposed to 4.x because BRISK is no longer in the main repository on 5.x (it moved to opencv_contrib). `Features2d_BRISK.descriptors_of_sub_matrix` computes keypoints, angles and descriptors on a continuous image and on a region of a larger image with unrelated pixels around it and requires identical output. On 4.x it fails (1 descriptor mismatch, 68 angle mismatches) and passes with the change. Continuous images are unchanged. Checks run on macOS arm64 (Release); the BRISK tests that read opencv_extra images were not run. The open PR #28194 also edits `brisk.cpp` (keypoint orientation in `compute()`) at different lines. Thank you for taking a look. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake