Merge pull request #28887 from milllemonman:4.x

hal/riscv-rvv: implement laplacian #28887

OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1353

An implementation of laplacian for riscv-rvv hal

Added benchmark in perf_laplacian.cpp
The performance is evaluated on K1 by running 
./opencv_perf_imgproc --gtest_filter="Perf_Laplacian*"
Results are attached in the figure below.

CV_8U fast path supports ksize=3 with BORDER_CONSTANT/BORDER_REPLICATE; unsupported combinations fall back to default implementation. See performance results bellow.

### 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
- [ ] 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
This commit is contained in:
Alex Wu
2026-05-06 21:05:28 +08:00
committed by GitHub
parent 6c0699c8c3
commit 30fffe2fa0
5 changed files with 590 additions and 0 deletions

View File

@@ -750,6 +750,22 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
if( ksize == 1 || ksize == 3 )
{
Mat src = _src.getMat();
Mat dst = _dst.getMat();
Point ofs;
Size wsz(src.cols, src.rows);
if(!(borderType & BORDER_ISOLATED))
src.locateROI(wsz, ofs);
CALL_HAL(laplacian, cv_hal_laplacian,
src.ptr(), src.step,
dst.ptr(), dst.step,
src.cols, src.rows,
sdepth, ddepth, cn,
ksize, borderType & ~BORDER_ISOLATED,
(uint8_t)0);
filter2D( _src, _dst, ddepth, kernel, Point(-1, -1), delta, borderType );
}
else