feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
		
							
								
								
									
										77
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/opencl/perf_stereobm.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/opencl/perf_stereobm.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,77 @@
 | 
			
		||||
/*M///////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
 | 
			
		||||
//
 | 
			
		||||
//  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
 | 
			
		||||
//
 | 
			
		||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
 | 
			
		||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., 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:
 | 
			
		||||
//
 | 
			
		||||
//   * Redistribution's of source code must retain the above copyright notice,
 | 
			
		||||
//     this list of conditions and the following disclaimer.
 | 
			
		||||
//
 | 
			
		||||
//   * Redistribution's 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.
 | 
			
		||||
//
 | 
			
		||||
//   * The name of the copyright holders may not 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 the Intel Corporation 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 "opencv2/ts/ocl_perf.hpp"
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_OPENCL
 | 
			
		||||
 | 
			
		||||
namespace opencv_test {
 | 
			
		||||
namespace ocl {
 | 
			
		||||
 | 
			
		||||
typedef tuple<int, int> StereoBMFixture_t;
 | 
			
		||||
typedef TestBaseWithParam<StereoBMFixture_t> StereoBMFixture;
 | 
			
		||||
 | 
			
		||||
OCL_PERF_TEST_P(StereoBMFixture, StereoBM, ::testing::Combine(OCL_PERF_ENUM(32, 64, 128), OCL_PERF_ENUM(11,21) ) )
 | 
			
		||||
{
 | 
			
		||||
    const int n_disp = get<0>(GetParam()), winSize = get<1>(GetParam());
 | 
			
		||||
    UMat left, right, disp;
 | 
			
		||||
 | 
			
		||||
    imread(getDataPath("gpu/stereobm/aloe-L.png"), IMREAD_GRAYSCALE).copyTo(left);
 | 
			
		||||
    imread(getDataPath("gpu/stereobm/aloe-R.png"), IMREAD_GRAYSCALE).copyTo(right);
 | 
			
		||||
    ASSERT_FALSE(left.empty());
 | 
			
		||||
    ASSERT_FALSE(right.empty());
 | 
			
		||||
 | 
			
		||||
    declare.in(left, right);
 | 
			
		||||
 | 
			
		||||
    Ptr<StereoBM> bm = StereoBM::create( n_disp, winSize );
 | 
			
		||||
    bm->setPreFilterType(bm->PREFILTER_XSOBEL);
 | 
			
		||||
    bm->setTextureThreshold(0);
 | 
			
		||||
 | 
			
		||||
    OCL_TEST_CYCLE() bm->compute(left, right, disp);
 | 
			
		||||
 | 
			
		||||
    SANITY_CHECK(disp, 1e-3, ERROR_RELATIVE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}//ocl
 | 
			
		||||
}//cvtest
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										165
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_affine2d.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_affine2d.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
							
								
								
									
										42
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_cicrlesGrid.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_cicrlesGrid.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
			
		||||
#include "perf_precomp.hpp"
 | 
			
		||||
 | 
			
		||||
namespace opencv_test
 | 
			
		||||
{
 | 
			
		||||
using namespace perf;
 | 
			
		||||
 | 
			
		||||
typedef tuple<std::string, cv::Size> String_Size_t;
 | 
			
		||||
typedef perf::TestBaseWithParam<String_Size_t> String_Size;
 | 
			
		||||
 | 
			
		||||
PERF_TEST_P(String_Size, asymm_circles_grid, testing::Values(
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles1.png", Size(7,13)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles2.png", Size(7,13)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles3.png", Size(7,13)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles4.png", Size(5,5)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles5.png", Size(5,5)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles6.png", Size(5,5)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles7.png", Size(3,9)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles8.png", Size(3,9)),
 | 
			
		||||
                String_Size_t("cv/cameracalibration/asymmetric_circles/acircles9.png", Size(3,9))
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
{
 | 
			
		||||
    string filename = getDataPath(get<0>(GetParam()));
 | 
			
		||||
    Size gridSize = get<1>(GetParam());
 | 
			
		||||
 | 
			
		||||
    Mat frame = imread(filename);
 | 
			
		||||
    if (frame.empty())
 | 
			
		||||
        FAIL() << "Unable to load source image " << filename;
 | 
			
		||||
 | 
			
		||||
    vector<Point2f> ptvec;
 | 
			
		||||
    ptvec.resize(gridSize.area());
 | 
			
		||||
 | 
			
		||||
    cvtColor(frame, frame, COLOR_BGR2GRAY);
 | 
			
		||||
 | 
			
		||||
    declare.in(frame).out(ptvec);
 | 
			
		||||
 | 
			
		||||
    TEST_CYCLE() ASSERT_TRUE(findCirclesGrid(frame, gridSize, ptvec, CALIB_CB_CLUSTERING | CALIB_CB_ASYMMETRIC_GRID));
 | 
			
		||||
 | 
			
		||||
    SANITY_CHECK(ptvec, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace
 | 
			
		||||
							
								
								
									
										7
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_main.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_main.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#include "perf_precomp.hpp"
 | 
			
		||||
 | 
			
		||||
#if defined(HAVE_HPX)
 | 
			
		||||
    #include <hpx/hpx_main.hpp>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
CV_PERF_TEST_MAIN(calib3d)
 | 
			
		||||
							
								
								
									
										150
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_pnp.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_pnp.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,150 @@
 | 
			
		||||
#include "perf_precomp.hpp"
 | 
			
		||||
 | 
			
		||||
namespace opencv_test
 | 
			
		||||
{
 | 
			
		||||
using namespace perf;
 | 
			
		||||
 | 
			
		||||
CV_ENUM(pnpAlgo, SOLVEPNP_ITERATIVE, SOLVEPNP_EPNP, SOLVEPNP_P3P, SOLVEPNP_DLS, SOLVEPNP_UPNP)
 | 
			
		||||
 | 
			
		||||
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)SOLVEPNP_UPNP, (int)SOLVEPNP_DLS)
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
{
 | 
			
		||||
    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
 | 
			
		||||
    Mat noise(1, (int)points2d.size(), 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);
 | 
			
		||||
    SANITY_CHECK(tvec, 1e-4);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PERF_TEST_P(PointsNum_Algo, solvePnPSmallPoints,
 | 
			
		||||
            testing::Combine(
 | 
			
		||||
                testing::Values(5),
 | 
			
		||||
                testing::Values((int)SOLVEPNP_P3P, (int)SOLVEPNP_EPNP, (int)SOLVEPNP_DLS, (int)SOLVEPNP_UPNP)
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
{
 | 
			
		||||
    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
 | 
			
		||||
    Mat noise(1, (int)points2d.size(), 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
 | 
			
		||||
							
								
								
									
										10
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_precomp.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_precomp.hpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
// 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/calib3d.hpp"
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										182
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_stereosgbm.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_stereosgbm.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,182 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  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)
 | 
			
		||||
 *
 | 
			
		||||
 *  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.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "perf_precomp.hpp"
 | 
			
		||||
 | 
			
		||||
namespace opencv_test
 | 
			
		||||
{
 | 
			
		||||
using namespace perf;
 | 
			
		||||
using namespace testing;
 | 
			
		||||
 | 
			
		||||
static void MakeArtificialExample(Mat& dst_left_view, Mat& dst_view);
 | 
			
		||||
 | 
			
		||||
CV_ENUM(SGBMModes, StereoSGBM::MODE_SGBM, StereoSGBM::MODE_SGBM_3WAY, StereoSGBM::MODE_HH4);
 | 
			
		||||
typedef tuple<Size, int, SGBMModes> SGBMParams;
 | 
			
		||||
typedef TestBaseWithParam<SGBMParams> TestStereoCorrespSGBM;
 | 
			
		||||
 | 
			
		||||
#ifndef _DEBUG
 | 
			
		||||
PERF_TEST_P( TestStereoCorrespSGBM, SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
 | 
			
		||||
#else
 | 
			
		||||
PERF_TEST_P( TestStereoCorrespSGBM, DISABLED_TooLongInDebug_SGBM, Combine(Values(Size(1280,720),Size(640,480)), Values(256,128), SGBMModes::all()) )
 | 
			
		||||
#endif
 | 
			
		||||
{
 | 
			
		||||
    SGBMParams params = GetParam();
 | 
			
		||||
 | 
			
		||||
    Size sz              = get<0>(params);
 | 
			
		||||
    int num_disparities  = get<1>(params);
 | 
			
		||||
    int mode             = get<2>(params);
 | 
			
		||||
 | 
			
		||||
    Mat src_left(sz, CV_8UC3);
 | 
			
		||||
    Mat src_right(sz, CV_8UC3);
 | 
			
		||||
    Mat dst(sz, CV_16S);
 | 
			
		||||
 | 
			
		||||
    MakeArtificialExample(src_left,src_right);
 | 
			
		||||
 | 
			
		||||
    int wsize = 3;
 | 
			
		||||
    int P1 = 8*src_left.channels()*wsize*wsize;
 | 
			
		||||
    TEST_CYCLE()
 | 
			
		||||
    {
 | 
			
		||||
        Ptr<StereoSGBM> sgbm = StereoSGBM::create(0,num_disparities,wsize,P1,4*P1,1,63,25,0,0,mode);
 | 
			
		||||
        sgbm->compute(src_left,src_right,dst);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SANITY_CHECK(dst, .01, ERROR_RELATIVE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef tuple<Size, int> BMParams;
 | 
			
		||||
typedef TestBaseWithParam<BMParams> TestStereoCorrespBM;
 | 
			
		||||
 | 
			
		||||
PERF_TEST_P(TestStereoCorrespBM, BM, Combine(Values(Size(1280, 720), Size(640, 480)), Values(256, 128)))
 | 
			
		||||
{
 | 
			
		||||
    BMParams params = GetParam();
 | 
			
		||||
    Size sz = get<0>(params);
 | 
			
		||||
    int num_disparities = get<1>(params);
 | 
			
		||||
 | 
			
		||||
    Mat src_left(sz, CV_8UC1);
 | 
			
		||||
    Mat src_right(sz, CV_8UC1);
 | 
			
		||||
    Mat dst(sz, CV_16S);
 | 
			
		||||
 | 
			
		||||
    MakeArtificialExample(src_left, src_right);
 | 
			
		||||
 | 
			
		||||
    int wsize = 21;
 | 
			
		||||
    TEST_CYCLE()
 | 
			
		||||
    {
 | 
			
		||||
        Ptr<StereoBM> bm = StereoBM::create(num_disparities, wsize);
 | 
			
		||||
        bm->compute(src_left, src_right, dst);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SANITY_CHECK(dst, .01, ERROR_RELATIVE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MakeArtificialExample(Mat& dst_left_view, Mat& dst_right_view)
 | 
			
		||||
{
 | 
			
		||||
    RNG rng(0);
 | 
			
		||||
    int w = dst_left_view.cols;
 | 
			
		||||
    int h = dst_left_view.rows;
 | 
			
		||||
 | 
			
		||||
    //params:
 | 
			
		||||
    unsigned char bg_level = (unsigned char)rng.uniform(0.0,255.0);
 | 
			
		||||
    unsigned char fg_level = (unsigned char)rng.uniform(0.0,255.0);
 | 
			
		||||
    int rect_width  = (int)rng.uniform(w/16,w/2);
 | 
			
		||||
    int rect_height = (int)rng.uniform(h/16,h/2);
 | 
			
		||||
    int rect_disparity = (int)(0.15*w);
 | 
			
		||||
    double sigma = 3.0;
 | 
			
		||||
 | 
			
		||||
    int rect_x_offset = (w-rect_width) /2;
 | 
			
		||||
    int rect_y_offset = (h-rect_height)/2;
 | 
			
		||||
 | 
			
		||||
    if(dst_left_view.channels()==3)
 | 
			
		||||
    {
 | 
			
		||||
        dst_left_view  = Scalar(Vec3b(bg_level,bg_level,bg_level));
 | 
			
		||||
        dst_right_view = Scalar(Vec3b(bg_level,bg_level,bg_level));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        dst_left_view  = Scalar(bg_level);
 | 
			
		||||
        dst_right_view = Scalar(bg_level);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Mat dst_left_view_rect = Mat(dst_left_view, Rect(rect_x_offset,rect_y_offset,rect_width,rect_height));
 | 
			
		||||
    if(dst_left_view.channels()==3)
 | 
			
		||||
        dst_left_view_rect = Scalar(Vec3b(fg_level,fg_level,fg_level));
 | 
			
		||||
    else
 | 
			
		||||
        dst_left_view_rect = Scalar(fg_level);
 | 
			
		||||
 | 
			
		||||
    rect_x_offset-=rect_disparity;
 | 
			
		||||
 | 
			
		||||
    Mat dst_right_view_rect = Mat(dst_right_view, Rect(rect_x_offset,rect_y_offset,rect_width,rect_height));
 | 
			
		||||
    if(dst_right_view.channels()==3)
 | 
			
		||||
        dst_right_view_rect = Scalar(Vec3b(fg_level,fg_level,fg_level));
 | 
			
		||||
    else
 | 
			
		||||
        dst_right_view_rect = Scalar(fg_level);
 | 
			
		||||
 | 
			
		||||
    //add some gaussian noise:
 | 
			
		||||
    unsigned char *l, *r;
 | 
			
		||||
    for(int i=0;i<h;i++)
 | 
			
		||||
    {
 | 
			
		||||
        l = dst_left_view.ptr(i);
 | 
			
		||||
        r = dst_right_view.ptr(i);
 | 
			
		||||
 | 
			
		||||
        if(dst_left_view.channels()==3)
 | 
			
		||||
        {
 | 
			
		||||
            for(int j=0;j<w;j++)
 | 
			
		||||
            {
 | 
			
		||||
                l[0] = saturate_cast<unsigned char>(l[0] + rng.gaussian(sigma));
 | 
			
		||||
                l[1] = saturate_cast<unsigned char>(l[1] + rng.gaussian(sigma));
 | 
			
		||||
                l[2] = saturate_cast<unsigned char>(l[2] + rng.gaussian(sigma));
 | 
			
		||||
                l+=3;
 | 
			
		||||
 | 
			
		||||
                r[0] = saturate_cast<unsigned char>(r[0] + rng.gaussian(sigma));
 | 
			
		||||
                r[1] = saturate_cast<unsigned char>(r[1] + rng.gaussian(sigma));
 | 
			
		||||
                r[2] = saturate_cast<unsigned char>(r[2] + rng.gaussian(sigma));
 | 
			
		||||
                r+=3;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            for(int j=0;j<w;j++)
 | 
			
		||||
            {
 | 
			
		||||
                l[0] = saturate_cast<unsigned char>(l[0] + rng.gaussian(sigma));
 | 
			
		||||
                l++;
 | 
			
		||||
 | 
			
		||||
                r[0] = saturate_cast<unsigned char>(r[0] + rng.gaussian(sigma));
 | 
			
		||||
                r++;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_undistort.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								3rdparty/opencv-4.5.4/modules/calib3d/perf/perf_undistort.cpp
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
// 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();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace
 | 
			
		||||
		Reference in New Issue
	
	Block a user