mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-17 07:04:18 +08:00

Depends on https://github.com/opencv/opencv/pull/26316 ### 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 - [ ] 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
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "perf_precomp.hpp"
|
|
|
|
namespace opencv_test {
|
|
|
|
typedef std::tuple<cv::Size, MatType, int /*iterations*/, float /*epsilon*/, Size /*winSize*/> MeanShiftPerfParams;
|
|
typedef perf::TestBaseWithParam<MeanShiftPerfParams> MeanShiftPerfTest;
|
|
|
|
PERF_TEST_P(MeanShiftPerfTest, run,
|
|
::testing::Combine(::testing::Values(Size(128, 128), Size(640, 480), Size(800, 600)),
|
|
::testing::Values(CV_8U, CV_32S, CV_32F), // type
|
|
::testing::Values(2, 10, 100), // nIterations
|
|
::testing::Values(0.01f, 0.1f, 1.f, 10.f), // epsilon
|
|
::testing::Values(Size(8, 8), Size(13, 48), Size(64, 64)) // window size
|
|
)
|
|
)
|
|
{
|
|
auto p = GetParam();
|
|
cv::Size size = std::get<0>(p);
|
|
MatType type = std::get<1>(p);
|
|
int iters = std::get<2>(p);
|
|
float eps = std::get<3>(p);
|
|
Size winSize = std::get<4>(p);
|
|
|
|
RNG& rng = cv::theRNG();
|
|
|
|
const int nPts = 20;
|
|
Mat ptsMap(size, CV_8UC1, Scalar(255));
|
|
for(size_t i = 0; i < nPts; ++i)
|
|
{
|
|
ptsMap.at<uchar>(rng() % size.height, rng() % size.width) = 0;
|
|
}
|
|
Mat distTrans(size, CV_8UC1);
|
|
cv::distanceTransform(ptsMap, distTrans, DIST_L2, DIST_MASK_PRECISE);
|
|
Mat vsrc = 255 - distTrans;
|
|
Mat src;
|
|
vsrc.convertTo(src, type);
|
|
|
|
Point startPt(rng() % (size.width - winSize.width),
|
|
rng() % (size.height - winSize.height));
|
|
Rect startRect(startPt, winSize);
|
|
|
|
cv::TermCriteria termCrit( TermCriteria::EPS + TermCriteria::MAX_ITER, iters, eps);
|
|
|
|
Rect window = startRect;
|
|
while(next())
|
|
{
|
|
startTimer();
|
|
cv::fastcv::meanShift(src, window, termCrit);
|
|
stopTimer();
|
|
}
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
} // namespace
|