mirror of
https://github.com/opencv/opencv.git
synced 2026-09-12 13:23:03 -05:00
Merge pull request #29393 from amd:fast_moments
imgproc: Optimized Moments & perf test added - #29393 - Added dispatch for moments (CV_8U, CV_16U, CV_32F and CV_64F) - CV_16S is kept in scalar due to regresssions observed. - Perf test added for meanShift, CamShift and matchShapes. - Extend Moments1 perf coverage to CV_8U alongside 16/32/64-bit depths. ### 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 - [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
This commit is contained in:
committed by
GitHub
parent
e39c9a2411
commit
a15bcc7ea8
85
modules/video/perf/perf_camshift.cpp
Normal file
85
modules/video/perf/perf_camshift.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
// 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
|
||||
// Copyright (C) 2026, Advanced Micro Devices, Inc., all rights reserved.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
using namespace perf;
|
||||
|
||||
typedef perf::TestBaseWithParam< tuple<Size, int> > MeanShiftFixture;
|
||||
typedef perf::TestBaseWithParam< tuple<Size, int> > CamShiftFixture;
|
||||
|
||||
static void initProbImage(const Size& size, Mat& prob, Rect& window)
|
||||
{
|
||||
prob.create(size, CV_32FC1);
|
||||
prob.setTo(0);
|
||||
|
||||
const Point center(size.width / 2, size.height / 2);
|
||||
const int radius = std::max(8, std::min(size.width, size.height) / 8);
|
||||
circle(prob, center, radius, Scalar(1.f), -1);
|
||||
|
||||
const int winSize = std::max(16, std::min(size.width, size.height) / 4);
|
||||
window = Rect(center.x - winSize / 2, center.y - winSize / 2, winSize, winSize);
|
||||
window &= Rect(0, 0, size.width, size.height);
|
||||
}
|
||||
|
||||
PERF_TEST_P(MeanShiftFixture, meanShift,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(5, 10, 20)))
|
||||
{
|
||||
const Size size = get<0>(GetParam());
|
||||
const int maxCount = get<1>(GetParam());
|
||||
|
||||
Mat prob;
|
||||
Rect window, initWindow;
|
||||
initProbImage(size, prob, initWindow);
|
||||
|
||||
declare.in(prob);
|
||||
|
||||
const TermCriteria criteria(TermCriteria::MAX_ITER | TermCriteria::EPS, maxCount, 1.0);
|
||||
int iters = 0;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
window = initWindow;
|
||||
iters = cv::meanShift(prob, window, criteria);
|
||||
}
|
||||
|
||||
SANITY_CHECK(iters);
|
||||
}
|
||||
|
||||
PERF_TEST_P(CamShiftFixture, CamShift,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p),
|
||||
testing::Values(5, 10, 20)))
|
||||
{
|
||||
const Size size = get<0>(GetParam());
|
||||
const int maxCount = get<1>(GetParam());
|
||||
|
||||
Mat prob;
|
||||
Rect window, initWindow;
|
||||
initProbImage(size, prob, initWindow);
|
||||
|
||||
declare.in(prob);
|
||||
|
||||
const TermCriteria criteria(TermCriteria::MAX_ITER | TermCriteria::EPS, maxCount, 1.0);
|
||||
RotatedRect box;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
window = initWindow;
|
||||
box = cv::CamShift(prob, window, criteria);
|
||||
}
|
||||
|
||||
const float boxWidth = box.size.width;
|
||||
const float boxHeight = box.size.height;
|
||||
SANITY_CHECK(boxWidth);
|
||||
SANITY_CHECK(boxHeight);
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
Reference in New Issue
Block a user