Files
opencv-MIRROR/modules/imgproc/perf/perf_matchShapes.cpp
Madan mohan Manokar a15bcc7ea8 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
2026-09-03 16:38:40 +03:00

53 lines
1.6 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
// Copyright (C) 2026, Advanced Micro Devices, Inc., all rights reserved.
#include "perf_precomp.hpp"
namespace opencv_test {
CV_ENUM(MatchShapeMethod, CONTOURS_MATCH_I1, CONTOURS_MATCH_I2, CONTOURS_MATCH_I3)
typedef perf::TestBaseWithParam< tuple<int, MatchShapeMethod> > MatchShapesFixture;
static void generateContour(int npoints, Mat& contour)
{
RNG& rng = theRNG();
contour.create(npoints, 1, CV_32SC2);
Point* pts = contour.ptr<Point>();
const Point center(rng.uniform(200, 400), rng.uniform(200, 400));
const int radius = rng.uniform(50, 150);
for (int i = 0; i < npoints; ++i)
{
const double angle = 2 * CV_PI * i / npoints;
pts[i].x = center.x + cvRound(radius * cos(angle));
pts[i].y = center.y + cvRound(radius * sin(angle));
}
}
PERF_TEST_P(MatchShapesFixture, matchShapes,
testing::Combine(
testing::Values(64, 256, 1024),
MatchShapeMethod::all()))
{
const int npoints = get<0>(GetParam());
const int method = get<1>(GetParam());
Mat contour1, contour2;
generateContour(npoints, contour1);
generateContour(npoints, contour2);
declare.in(contour1).in(contour2);
double dist = 0;
TEST_CYCLE()
{
dist = cv::matchShapes(contour1, contour2, method, 0);
}
SANITY_CHECK(dist, 1e-3, ERROR_RELATIVE);
}
} // namespace opencv_test