vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
// 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"
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
using namespace perf;
|
||||
|
||||
typedef TestBaseWithParam< tuple<MatDepth, int> > TestBoundingRect;
|
||||
|
||||
PERF_TEST_P(TestBoundingRect, BoundingRect,
|
||||
Combine(
|
||||
testing::Values(CV_32S, CV_32F), // points type
|
||||
Values(400, 511, 1000, 10000, 100000) // points count
|
||||
)
|
||||
)
|
||||
|
||||
{
|
||||
int ptType = get<0>(GetParam());
|
||||
int n = get<1>(GetParam());
|
||||
|
||||
Mat pts(n, 2, ptType);
|
||||
declare.in(pts, WARMUP_RNG);
|
||||
|
||||
cv::Rect rect;
|
||||
TEST_CYCLE() rect = boundingRect(pts);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< tuple<MatDepth, int> > TestMinEnclosingCircle;
|
||||
PERF_TEST_P(TestMinEnclosingCircle, minEnclosingCircle,
|
||||
Combine(
|
||||
testing::Values(CV_32S, CV_32F),
|
||||
Values(400, 1000, 10000, 100000)
|
||||
))
|
||||
{
|
||||
int ptType = get<0>(GetParam());
|
||||
int n = get<1>(GetParam());
|
||||
Mat pts(n, 2, ptType);
|
||||
declare.in(pts, WARMUP_RNG);
|
||||
|
||||
Point2f center;
|
||||
float radius;
|
||||
TEST_CYCLE() minEnclosingCircle(pts, center, radius);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam<int> TestMinEnclosingCircleWorstCase;
|
||||
PERF_TEST_P(TestMinEnclosingCircleWorstCase, minEnclosingCircle_sequential,
|
||||
Values(400, 1000, 5000, 10000))
|
||||
{
|
||||
int n = GetParam();
|
||||
vector<Point2f> contour;
|
||||
for(int i = 0; i < n; ++i) {
|
||||
float angle = (float)(i * 2 * CV_PI / n);
|
||||
contour.push_back(Point2f(cos(angle) * 100, sin(angle) * 100));
|
||||
}
|
||||
|
||||
Point2f center;
|
||||
float radius;
|
||||
TEST_CYCLE() minEnclosingCircle(contour, center, radius);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,165 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
// (3-clause BSD License)
|
||||
//
|
||||
// Copyright (C) 2015-2016, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the names of the copyright holders nor the names of the contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall copyright holders or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(Method, RANSAC, LMEDS)
|
||||
typedef tuple<int, double, Method, size_t> AffineParams;
|
||||
typedef TestBaseWithParam<AffineParams> EstimateAffine;
|
||||
#define ESTIMATE_PARAMS Combine(Values(100000, 5000, 100), Values(0.99, 0.95, 0.9), Method::all(), Values(10, 0))
|
||||
|
||||
static float rngIn(float from, float to) { return from + (to-from) * (float)theRNG(); }
|
||||
|
||||
static Mat rngPartialAffMat() {
|
||||
double theta = rngIn(0, (float)CV_PI*2.f);
|
||||
double scale = rngIn(0, 3);
|
||||
double tx = rngIn(-2, 2);
|
||||
double ty = rngIn(-2, 2);
|
||||
double aff[2*3] = { std::cos(theta) * scale, -std::sin(theta) * scale, tx,
|
||||
std::sin(theta) * scale, std::cos(theta) * scale, ty };
|
||||
return Mat(2, 3, CV_64F, aff).clone();
|
||||
}
|
||||
|
||||
PERF_TEST_P( EstimateAffine, EstimateAffine2D, ESTIMATE_PARAMS )
|
||||
{
|
||||
AffineParams params = GetParam();
|
||||
const int n = get<0>(params);
|
||||
const double confidence = get<1>(params);
|
||||
const int method = get<2>(params);
|
||||
const size_t refining = get<3>(params);
|
||||
|
||||
Mat aff(2, 3, CV_64F);
|
||||
cv::randu(aff, -2., 2.);
|
||||
|
||||
// LMEDS can't handle more than 50% outliers (by design)
|
||||
int m;
|
||||
if (method == LMEDS)
|
||||
m = 3*n/5;
|
||||
else
|
||||
m = 2*n/5;
|
||||
const float shift_outl = 15.f;
|
||||
const float noise_level = 20.f;
|
||||
|
||||
Mat fpts(1, n, CV_32FC2);
|
||||
Mat tpts(1, n, CV_32FC2);
|
||||
|
||||
randu(fpts, 0., 100.);
|
||||
transform(fpts, tpts, aff);
|
||||
|
||||
/* adding noise to some points */
|
||||
Mat outliers = tpts.colRange(m, n);
|
||||
outliers.reshape(1) += shift_outl;
|
||||
|
||||
Mat noise (outliers.size(), outliers.type());
|
||||
randu(noise, 0., noise_level);
|
||||
outliers += noise;
|
||||
|
||||
Mat aff_est;
|
||||
vector<uchar> inliers (n);
|
||||
|
||||
warmup(inliers, WARMUP_WRITE);
|
||||
warmup(fpts, WARMUP_READ);
|
||||
warmup(tpts, WARMUP_READ);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
aff_est = estimateAffine2D(fpts, tpts, inliers, method, 3, 2000, confidence, refining);
|
||||
}
|
||||
|
||||
// we already have accuracy tests
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P( EstimateAffine, EstimateAffinePartial2D, ESTIMATE_PARAMS )
|
||||
{
|
||||
AffineParams params = GetParam();
|
||||
const int n = get<0>(params);
|
||||
const double confidence = get<1>(params);
|
||||
const int method = get<2>(params);
|
||||
const size_t refining = get<3>(params);
|
||||
|
||||
Mat aff = rngPartialAffMat();
|
||||
|
||||
int m;
|
||||
// LMEDS can't handle more than 50% outliers (by design)
|
||||
if (method == LMEDS)
|
||||
m = 3*n/5;
|
||||
else
|
||||
m = 2*n/5;
|
||||
const float shift_outl = 15.f; const float noise_level = 20.f;
|
||||
|
||||
Mat fpts(1, n, CV_32FC2);
|
||||
Mat tpts(1, n, CV_32FC2);
|
||||
|
||||
randu(fpts, 0., 100.);
|
||||
transform(fpts, tpts, aff);
|
||||
|
||||
/* adding noise*/
|
||||
Mat outliers = tpts.colRange(m, n);
|
||||
outliers.reshape(1) += shift_outl;
|
||||
|
||||
Mat noise (outliers.size(), outliers.type());
|
||||
randu(noise, 0., noise_level);
|
||||
outliers += noise;
|
||||
|
||||
Mat aff_est;
|
||||
vector<uchar> inliers (n);
|
||||
|
||||
warmup(inliers, WARMUP_WRITE);
|
||||
warmup(fpts, WARMUP_READ);
|
||||
warmup(tpts, WARMUP_READ);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
aff_est = estimateAffinePartial2D(fpts, tpts, inliers, method, 3, 2000, confidence, refining);
|
||||
}
|
||||
|
||||
// we already have accuracy tests
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_HPX)
|
||||
#include <hpx/hpx_main.hpp>
|
||||
#endif
|
||||
|
||||
CV_PERF_TEST_MAIN(calib3d)
|
||||
@@ -0,0 +1,41 @@
|
||||
// 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) 2014, Itseez, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
typedef tuple<Size, MatDepth, bool> MomentsParams_t;
|
||||
typedef perf::TestBaseWithParam<MomentsParams_t> MomentsFixture_val;
|
||||
|
||||
PERF_TEST_P(MomentsFixture_val, Moments1,
|
||||
::testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_16U, CV_16S, CV_32F, CV_64F),
|
||||
testing::Bool()))
|
||||
{
|
||||
const MomentsParams_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const MatDepth srcDepth = get<1>(params);
|
||||
const bool binaryImage = get<2>(params);
|
||||
|
||||
cv::Moments m;
|
||||
Mat src(srcSize, srcDepth);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() m = cv::moments(src, binaryImage);
|
||||
|
||||
int len = (int)sizeof(cv::Moments) / sizeof(double);
|
||||
cv::Mat mat(1, len, CV_64F, (void*)&m);
|
||||
//adding 1 to moments to avoid accidental tests fail on values close to 0
|
||||
mat += 1;
|
||||
|
||||
|
||||
SANITY_CHECK_MOMENTS(m, 3.3e-4, ERROR_RELATIVE);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,153 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
CV_ENUM(pnpAlgo, SOLVEPNP_ITERATIVE, SOLVEPNP_EPNP, SOLVEPNP_P3P)
|
||||
|
||||
typedef tuple<int, pnpAlgo> PointsNum_Algo_t;
|
||||
typedef perf::TestBaseWithParam<PointsNum_Algo_t> PointsNum_Algo;
|
||||
|
||||
typedef perf::TestBaseWithParam<int> PointsNum;
|
||||
|
||||
PERF_TEST_P(PointsNum_Algo, solvePnP,
|
||||
testing::Combine( //When non planar, DLT needs at least 6 points for SOLVEPNP_ITERATIVE flag
|
||||
testing::Values(6, 3*9, 7*13), //TODO: find why results on 4 points are too unstable
|
||||
testing::Values((int)SOLVEPNP_ITERATIVE, (int)SOLVEPNP_EPNP)
|
||||
)
|
||||
)
|
||||
{
|
||||
int pointsNum = get<0>(GetParam());
|
||||
pnpAlgo algo = get<1>(GetParam());
|
||||
|
||||
vector<Point2f> points2d(pointsNum);
|
||||
vector<Point3f> points3d(pointsNum);
|
||||
Mat rvec = Mat::zeros(3, 1, CV_32FC1);
|
||||
Mat tvec = Mat::zeros(3, 1, CV_32FC1);
|
||||
|
||||
Mat distortion = Mat::zeros(5, 1, CV_32FC1);
|
||||
Mat intrinsics = Mat::eye(3, 3, CV_32FC1);
|
||||
intrinsics.at<float> (0, 0) = 400.0;
|
||||
intrinsics.at<float> (1, 1) = 400.0;
|
||||
intrinsics.at<float> (0, 2) = 640 / 2;
|
||||
intrinsics.at<float> (1, 2) = 480 / 2;
|
||||
|
||||
warmup(points3d, WARMUP_RNG);
|
||||
warmup(rvec, WARMUP_RNG);
|
||||
warmup(tvec, WARMUP_RNG);
|
||||
|
||||
projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
|
||||
|
||||
//add noise
|
||||
int sz = (int)points2d.size();
|
||||
Mat noise(1, &sz, CV_32FC2);
|
||||
randu(noise, 0, 0.01);
|
||||
cv::add(points2d, noise, points2d);
|
||||
|
||||
declare.in(points3d, points2d);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE_N(1000)
|
||||
{
|
||||
cv::solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
|
||||
}
|
||||
|
||||
SANITY_CHECK(rvec, 1e-4);
|
||||
// the check is relaxed from 1e-4 to 2e-2 after LevMarq replacement
|
||||
SANITY_CHECK(tvec, 2e-2);
|
||||
}
|
||||
|
||||
PERF_TEST_P(PointsNum_Algo, solvePnPSmallPoints,
|
||||
testing::Combine(
|
||||
testing::Values(5),
|
||||
testing::Values((int)SOLVEPNP_P3P, (int)SOLVEPNP_EPNP)
|
||||
)
|
||||
)
|
||||
{
|
||||
int pointsNum = get<0>(GetParam());
|
||||
pnpAlgo algo = get<1>(GetParam());
|
||||
if( algo == SOLVEPNP_P3P )
|
||||
pointsNum = 4;
|
||||
|
||||
vector<Point2f> points2d(pointsNum);
|
||||
vector<Point3f> points3d(pointsNum);
|
||||
Mat rvec = Mat::zeros(3, 1, CV_32FC1);
|
||||
Mat tvec = Mat::zeros(3, 1, CV_32FC1);
|
||||
|
||||
Mat distortion = Mat::zeros(5, 1, CV_32FC1);
|
||||
Mat intrinsics = Mat::eye(3, 3, CV_32FC1);
|
||||
intrinsics.at<float> (0, 0) = 400.0f;
|
||||
intrinsics.at<float> (1, 1) = 400.0f;
|
||||
intrinsics.at<float> (0, 2) = 640 / 2;
|
||||
intrinsics.at<float> (1, 2) = 480 / 2;
|
||||
|
||||
warmup(points3d, WARMUP_RNG);
|
||||
warmup(rvec, WARMUP_RNG);
|
||||
warmup(tvec, WARMUP_RNG);
|
||||
|
||||
// normalize Rodrigues vector
|
||||
Mat rvec_tmp = Mat::eye(3, 3, CV_32F);
|
||||
cv::Rodrigues(rvec, rvec_tmp);
|
||||
cv::Rodrigues(rvec_tmp, rvec);
|
||||
|
||||
cv::projectPoints(points3d, rvec, tvec, intrinsics, distortion, points2d);
|
||||
|
||||
//add noise
|
||||
int npoints = (int)points2d.size();
|
||||
Mat noise(1, &npoints, CV_32FC2);
|
||||
randu(noise, -0.001, 0.001);
|
||||
cv::add(points2d, noise, points2d);
|
||||
|
||||
declare.in(points3d, points2d);
|
||||
declare.time(100);
|
||||
|
||||
TEST_CYCLE_N(1000)
|
||||
{
|
||||
cv::solvePnP(points3d, points2d, intrinsics, distortion, rvec, tvec, false, algo);
|
||||
}
|
||||
|
||||
SANITY_CHECK(rvec, 1e-1);
|
||||
SANITY_CHECK(tvec, 1e-2);
|
||||
}
|
||||
|
||||
PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(5, 3*9, 7*13))
|
||||
{
|
||||
int count = GetParam();
|
||||
|
||||
Mat object(1, count, CV_32FC3);
|
||||
randu(object, -100, 100);
|
||||
|
||||
Mat camera_mat(3, 3, CV_32FC1);
|
||||
randu(camera_mat, 0.5, 1);
|
||||
camera_mat.at<float>(0, 1) = 0.f;
|
||||
camera_mat.at<float>(1, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 0) = 0.f;
|
||||
camera_mat.at<float>(2, 1) = 0.f;
|
||||
|
||||
Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
|
||||
|
||||
vector<cv::Point2f> image_vec;
|
||||
|
||||
Mat rvec_gold(1, 3, CV_32FC1);
|
||||
randu(rvec_gold, 0, 1);
|
||||
|
||||
Mat tvec_gold(1, 3, CV_32FC1);
|
||||
randu(tvec_gold, 0, 1);
|
||||
projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
|
||||
|
||||
Mat image(1, count, CV_32FC2, &image_vec[0]);
|
||||
|
||||
Mat rvec;
|
||||
Mat tvec;
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
|
||||
}
|
||||
|
||||
SANITY_CHECK(rvec, 1e-6);
|
||||
SANITY_CHECK(tvec, 1e-6);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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
|
||||
#ifndef __OPENCV_PERF_PRECOMP_HPP__
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/geometry.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
#include <opencv2/core/ocl.hpp>
|
||||
#endif
|
||||
|
||||
namespace opencv_test {
|
||||
using namespace perf;
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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 {
|
||||
|
||||
PERF_TEST(Undistort, InitUndistortMap)
|
||||
{
|
||||
Size size_w_h(512 + 3, 512);
|
||||
Mat k(3, 3, CV_32FC1);
|
||||
Mat d(1, 14, CV_64FC1);
|
||||
Mat dst(size_w_h, CV_32FC2);
|
||||
declare.in(k, d, WARMUP_RNG).out(dst);
|
||||
TEST_CYCLE() initUndistortRectifyMap(k, d, noArray(), k, size_w_h, CV_32FC2, dst, noArray());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST(Undistort, DISABLED_InitInverseRectificationMap)
|
||||
{
|
||||
Size size_w_h(512 + 3, 512);
|
||||
Mat k(3, 3, CV_32FC1);
|
||||
Mat d(1, 14, CV_64FC1);
|
||||
Mat dst(size_w_h, CV_32FC2);
|
||||
declare.in(k, d, WARMUP_RNG).out(dst);
|
||||
TEST_CYCLE() initInverseRectificationMap(k, d, noArray(), k, size_w_h, CV_32FC2, dst, noArray());
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST(Undistort, fisheye_undistortPoints_100k_10iter)
|
||||
{
|
||||
const int pointsNumber = 100000;
|
||||
const Size imageSize(1280, 800);
|
||||
|
||||
/* Set camera matrix */
|
||||
const Matx33d K(558.478087865323, 0, 620.458515360843,
|
||||
0, 560.506767351568, 381.939424848348,
|
||||
0, 0, 1);
|
||||
|
||||
/* Set distortion coefficients */
|
||||
const Matx14d D(2.81e-06, 1.31e-06, -4.42e-06, -1.25e-06);
|
||||
|
||||
/* Create two-channel points matrix */
|
||||
Mat xy[2] = {};
|
||||
xy[0].create(pointsNumber, 1, CV_64F);
|
||||
theRNG().fill(xy[0], RNG::UNIFORM, 0, imageSize.width); // x
|
||||
xy[1].create(pointsNumber, 1, CV_64F);
|
||||
theRNG().fill(xy[1], RNG::UNIFORM, 0, imageSize.height); // y
|
||||
|
||||
Mat points;
|
||||
merge(xy, 2, points);
|
||||
|
||||
/* Set fixed iteration number to check only c++ code, not algo convergence */
|
||||
TermCriteria termCriteria(TermCriteria::MAX_ITER, 10, 0);
|
||||
|
||||
Mat undistortedPoints;
|
||||
TEST_CYCLE() fisheye::undistortPoints(points, undistortedPoints, K, D, noArray(), noArray(), termCriteria);
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user