1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-27 06:13:05 +04:00
Files
Alex Wu 30fffe2fa0 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
2026-05-06 16:05:28 +03:00

40 lines
1.2 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(BorderMode, BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101)
CV_ENUM(TargetDepth, CV_8U, CV_16S)
typedef tuple<Size, int, TargetDepth, BorderMode> LaplacianParams;
typedef perf::TestBaseWithParam<LaplacianParams> Perf_Laplacian;
PERF_TEST_P(Perf_Laplacian, Laplacian,
testing::Combine(
testing::Values(szVGA, sz720p, sz1080p),
testing::Values(1, 3, 5), // ksize: 1, 3, 5
TargetDepth::all(), // CV_8U and CV_16S
BorderMode::all()
))
{
Size sz = get<0>(GetParam());
int ksize = get<1>(GetParam());
int ddepth = get<2>(GetParam());
int borderMode = get<3>(GetParam());
Mat src(sz, CV_8UC1);
Mat dst(sz, ddepth == CV_16S ? CV_16SC1 : CV_8UC1);
declare.in(src, WARMUP_RNG).out(dst);
TEST_CYCLE()
{
cv::Laplacian(src, dst, ddepth, ksize, 1.0, 0.0, borderMode);
}
SANITY_CHECK(dst);
}
} // namespace opencv_test