Skip to content

Add RISC-V HAL implementation for cv::resize#27160

Merged
asmorkalov merged 4 commits intoopencv:4.xfrom
amane-ame:resize_hal_rvv
Mar 31, 2025
Merged

Add RISC-V HAL implementation for cv::resize#27160
asmorkalov merged 4 commits intoopencv:4.xfrom
amane-ame:resize_hal_rvv

Conversation

@amane-ame
Copy link
Copy Markdown
Contributor

@amane-ame amane-ame commented Mar 27, 2025

This patch implements cv_hal_resize using native intrinsics, optimizing the performance of cv::resize for CV_INTER_NEAREST/CV_INTER_NEAREST_EXACT/CV_INTER_LINEAR/CV_INTER_LINEAR_EXACT/CV_INTER_AREA modes.

Tested on MUSE-PI (Spacemit X60) for both gcc 14.2 and clang 20.1.

$ ./opencv_test_imgproc --gtest_filter="*Resize*:*resize*"
$ ./opencv_perf_imgproc --gtest_filter="*Resize*:*resize*" --perf_min_samples=300 --perf_force_samples=300

View the full perf table here: hal_rvv_resize.pdf

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

amane-ame and others added 2 commits March 26, 2025 16:31
Co-authored-by: Liutong HAN <liutong2020@iscas.ac.cn>
Co-authored-by: Liutong HAN <liutong2020@iscas.ac.cn>
Co-authored-by: Liutong HAN <liutong2020@iscas.ac.cn>
@asmorkalov asmorkalov self-requested a review March 27, 2025 10:30
@asmorkalov
Copy link
Copy Markdown
Contributor

I see sporadic test crash:

[----------] 8 tests from OCL_CornerHarrisFixture_CornerHarris
[ RUN      ] OCL_CornerHarrisFixture_CornerHarris.CornerHarris/0, where GetParam() = (640x480, 8UC1)
double free or corruption (!prev)
[1]    3022 abort (core dumped)  ./opencv_perf_imgproc --gtest_output=xml:../perf-resize/patched-2.xml

Co-authored-by: Liutong HAN <liutong2020@iscas.ac.cn>
@amane-ame
Copy link
Copy Markdown
Contributor Author

@asmorkalov Fixed.

@asmorkalov
Copy link
Copy Markdown
Contributor

My performance results for Muse Pi v30 (gcc 14.2):
perf-resize.zip

@asmorkalov asmorkalov added this to the 4.12.0 milestone Mar 31, 2025
@asmorkalov asmorkalov self-assigned this Mar 31, 2025
@asmorkalov
Copy link
Copy Markdown
Contributor

The sporadic crash disappeared. Thanks!

@asmorkalov asmorkalov merged commit 14e1f6c into opencv:4.x Mar 31, 2025
26 of 28 checks passed
@asmorkalov asmorkalov mentioned this pull request Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants