feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
169
3rdparty/opencv-4.5.4/modules/stitching/test/ocl/test_warpers.cpp
vendored
Normal file
169
3rdparty/opencv-4.5.4/modules/stitching/test/ocl/test_warpers.cpp
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
/*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-2013, 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 OpenCV Foundation 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 "../test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
#include "opencv2/stitching/warpers.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace opencv_test {
|
||||
namespace ocl {
|
||||
|
||||
struct WarperTestBase :
|
||||
public Test, public TestUtils
|
||||
{
|
||||
Mat src, dst, xmap, ymap;
|
||||
UMat usrc, udst, uxmap, uymap;
|
||||
Mat K, R;
|
||||
|
||||
void generateTestData()
|
||||
{
|
||||
Size size = randomSize(1, MAX_VALUE);
|
||||
|
||||
src = randomMat(size, CV_32FC1, -500, 500);
|
||||
src.copyTo(usrc);
|
||||
|
||||
K = Mat::eye(3, 3, CV_32FC1);
|
||||
float angle = (float)(30.0 * CV_PI / 180.0);
|
||||
float rotationMatrix[9] = {
|
||||
(float)cos(angle), (float)sin(angle), 0,
|
||||
(float)-sin(angle), (float)cos(angle), 0,
|
||||
0, 0, 1
|
||||
};
|
||||
Mat(3, 3, CV_32FC1, rotationMatrix).copyTo(R);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.)
|
||||
{
|
||||
EXPECT_MAT_NEAR(xmap, uxmap, threshold);
|
||||
EXPECT_MAT_NEAR(ymap, uymap, threshold);
|
||||
EXPECT_MAT_NEAR(dst, udst, threshold);
|
||||
}
|
||||
};
|
||||
|
||||
typedef WarperTestBase SphericalWarperTest;
|
||||
|
||||
OCL_TEST_F(SphericalWarperTest, Mat)
|
||||
{
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
|
||||
Ptr<WarperCreator> creator = makePtr<SphericalWarper>();
|
||||
Ptr<detail::RotationWarper> warper = creator->create(2.0);
|
||||
|
||||
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
|
||||
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
|
||||
|
||||
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
|
||||
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
|
||||
|
||||
Near(1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
typedef WarperTestBase CylindricalWarperTest;
|
||||
|
||||
OCL_TEST_F(CylindricalWarperTest, Mat)
|
||||
{
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
|
||||
Ptr<WarperCreator> creator = makePtr<CylindricalWarper>();
|
||||
Ptr<detail::RotationWarper> warper = creator->create(2.0);
|
||||
|
||||
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
|
||||
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
|
||||
|
||||
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
|
||||
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
|
||||
|
||||
Near(1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
typedef WarperTestBase PlaneWarperTest;
|
||||
|
||||
OCL_TEST_F(PlaneWarperTest, Mat)
|
||||
{
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
|
||||
Ptr<WarperCreator> creator = makePtr<PlaneWarper>();
|
||||
Ptr<detail::RotationWarper> warper = creator->create(2.0);
|
||||
|
||||
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
|
||||
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
|
||||
|
||||
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
|
||||
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
|
||||
|
||||
Near(1.5e-4);
|
||||
}
|
||||
}
|
||||
|
||||
typedef WarperTestBase AffineWarperTest;
|
||||
|
||||
OCL_TEST_F(AffineWarperTest, Mat)
|
||||
{
|
||||
for (int j = 0; j < test_loop_times; j++)
|
||||
{
|
||||
generateTestData();
|
||||
|
||||
Ptr<WarperCreator> creator = makePtr<AffineWarper>();
|
||||
Ptr<detail::RotationWarper> warper = creator->create(1.0);
|
||||
|
||||
OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap));
|
||||
OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap));
|
||||
|
||||
OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst));
|
||||
OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst));
|
||||
|
||||
Near(1.5e-4);
|
||||
}
|
||||
}
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
79
3rdparty/opencv-4.5.4/modules/stitching/test/test_blenders.cpp
vendored
Normal file
79
3rdparty/opencv-4.5.4/modules/stitching/test/test_blenders.cpp
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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 "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
TEST(MultiBandBlender, CanBlendTwoImages)
|
||||
{
|
||||
Mat image1 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/baboon.png");
|
||||
Mat image2 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/lena.png");
|
||||
ASSERT_EQ(image1.rows, image2.rows); ASSERT_EQ(image1.cols, image2.cols);
|
||||
|
||||
Mat image1s, image2s;
|
||||
image1.convertTo(image1s, CV_16S);
|
||||
image2.convertTo(image2s, CV_16S);
|
||||
|
||||
Mat mask1(image1s.size(), CV_8U);
|
||||
mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255);
|
||||
mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0);
|
||||
|
||||
Mat mask2(image2s.size(), CV_8U);
|
||||
mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0);
|
||||
mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255);
|
||||
|
||||
detail::MultiBandBlender blender(false, 5);
|
||||
|
||||
blender.prepare(Rect(0, 0, max(image1s.cols, image2s.cols), max(image1s.rows, image2s.rows)));
|
||||
blender.feed(image1s, mask1, Point(0,0));
|
||||
blender.feed(image2s, mask2, Point(0,0));
|
||||
|
||||
Mat result_s, result_mask;
|
||||
blender.blend(result_s, result_mask);
|
||||
Mat result; result_s.convertTo(result, CV_8U);
|
||||
|
||||
Mat expected = imread(string(cvtest::TS::ptr()->get_data_path()) + "stitching/baboon_lena.png");
|
||||
double psnr = cvtest::PSNR(expected, result);
|
||||
EXPECT_GE(psnr, 50);
|
||||
}
|
||||
|
||||
}} // namespace
|
93
3rdparty/opencv-4.5.4/modules/stitching/test/test_blenders.cuda.cpp
vendored
Normal file
93
3rdparty/opencv-4.5.4/modules/stitching/test/test_blenders.cuda.cpp
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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 "test_precomp.hpp"
|
||||
#include "opencv2/ts/cuda_test.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
|
||||
|
||||
void multiBandBlend(const cv::Mat& im1, const cv::Mat& im2, const cv::Mat& mask1, const cv::Mat& mask2, cv::Mat& result, bool try_cuda)
|
||||
{
|
||||
detail::MultiBandBlender blender(try_cuda, 5);
|
||||
|
||||
blender.prepare(Rect(0, 0, max(im1.cols, im2.cols), max(im1.rows, im2.rows)));
|
||||
|
||||
// If using cuda try blending multiple times without calling prepare inbetween
|
||||
for (int i = 0; i < (try_cuda ? 10 : 1); ++i) {
|
||||
blender.feed(im1, mask1, Point(0, 0));
|
||||
blender.feed(im2, mask2, Point(0, 0));
|
||||
|
||||
Mat result_s, result_mask;
|
||||
blender.blend(result_s, result_mask);
|
||||
result_s.convertTo(result, CV_8U);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CUDA_MultiBandBlender, Accuracy)
|
||||
{
|
||||
Mat image1 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/baboon.png");
|
||||
Mat image2 = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/lena.png");
|
||||
ASSERT_EQ(image1.rows, image2.rows); ASSERT_EQ(image1.cols, image2.cols);
|
||||
|
||||
Mat image1s, image2s;
|
||||
image1.convertTo(image1s, CV_16S);
|
||||
image2.convertTo(image2s, CV_16S);
|
||||
|
||||
Mat mask1(image1s.size(), CV_8U);
|
||||
mask1(Rect(0, 0, mask1.cols/2, mask1.rows)).setTo(255);
|
||||
mask1(Rect(mask1.cols/2, 0, mask1.cols - mask1.cols/2, mask1.rows)).setTo(0);
|
||||
|
||||
Mat mask2(image2s.size(), CV_8U);
|
||||
mask2(Rect(0, 0, mask2.cols/2, mask2.rows)).setTo(0);
|
||||
mask2(Rect(mask2.cols/2, 0, mask2.cols - mask2.cols/2, mask2.rows)).setTo(255);
|
||||
|
||||
cv::Mat result;
|
||||
multiBandBlend(image1s, image2s, mask1, mask2, result, false);
|
||||
|
||||
cv::Mat result_cuda;
|
||||
multiBandBlend(image1s, image2s, mask1, mask2, result_cuda, true);
|
||||
|
||||
EXPECT_MAT_NEAR(result, result_cuda, 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
}} // namespace
|
70
3rdparty/opencv-4.5.4/modules/stitching/test/test_exposure_compensate.cpp
vendored
Normal file
70
3rdparty/opencv-4.5.4/modules/stitching/test/test_exposure_compensate.cpp
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// 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 "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
namespace {
|
||||
|
||||
double minPSNR(UMat src1, UMat src2)
|
||||
{
|
||||
std::vector<UMat> src1_channels, src2_channels;
|
||||
split(src1, src1_channels);
|
||||
split(src2, src2_channels);
|
||||
|
||||
double psnr = cvtest::PSNR(src1_channels[0], src2_channels[0]);
|
||||
psnr = std::min(psnr, cvtest::PSNR(src1_channels[1], src2_channels[1]));
|
||||
return std::min(psnr, cvtest::PSNR(src1_channels[2], src2_channels[2]));
|
||||
}
|
||||
|
||||
TEST(ExposureCompensate, SimilarityThreshold)
|
||||
{
|
||||
UMat source;
|
||||
imread(cvtest::TS::ptr()->get_data_path() + "stitching/s1.jpg").copyTo(source);
|
||||
|
||||
UMat image1 = source.clone();
|
||||
UMat image2 = source.clone();
|
||||
|
||||
// Add a big artifact
|
||||
image2(Rect(150, 150, 100, 100)).setTo(Scalar(0, 0, 255));
|
||||
|
||||
UMat mask(image1.size(), CV_8U);
|
||||
mask.setTo(255);
|
||||
|
||||
detail::BlocksChannelsCompensator compensator;
|
||||
compensator.setNrGainsFilteringIterations(0); // makes it more clear
|
||||
|
||||
// Feed the compensator, image 1 and 2 are perfectly
|
||||
// identical, except for the red artifact in image 2
|
||||
// Apart from that artifact, there is no exposure to compensate
|
||||
compensator.setSimilarityThreshold(1);
|
||||
uchar xff = 255;
|
||||
compensator.feed(
|
||||
{{}, {}},
|
||||
{image1, image2},
|
||||
{{mask, xff}, {mask, xff}}
|
||||
);
|
||||
// Verify that the artifact in image 2 did create
|
||||
// an artifact in image1 during the exposure compensation
|
||||
UMat image1_result = image1.clone();
|
||||
compensator.apply(0, {}, image1_result, mask);
|
||||
double psnr_no_similarity_mask = minPSNR(image1, image1_result);
|
||||
EXPECT_LT(psnr_no_similarity_mask, 45);
|
||||
|
||||
// Add a similarity threshold and verify that
|
||||
// the artifact in image1 is gone
|
||||
compensator.setSimilarityThreshold(0.1);
|
||||
compensator.feed(
|
||||
{{}, {}},
|
||||
{image1, image2},
|
||||
{{mask, xff}, {mask, xff}}
|
||||
);
|
||||
image1_result = image1.clone();
|
||||
compensator.apply(0, {}, image1_result, mask);
|
||||
double psnr_similarity_mask = minPSNR(image1, image1_result);
|
||||
EXPECT_GT(psnr_similarity_mask, 300);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opencv_test
|
10
3rdparty/opencv-4.5.4/modules/stitching/test/test_main.cpp
vendored
Normal file
10
3rdparty/opencv-4.5.4/modules/stitching/test/test_main.cpp
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.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_HPX)
|
||||
#include <hpx/hpx_main.hpp>
|
||||
#endif
|
||||
|
||||
CV_TEST_MAIN(".")
|
117
3rdparty/opencv-4.5.4/modules/stitching/test/test_matchers.cpp
vendored
Normal file
117
3rdparty/opencv-4.5.4/modules/stitching/test/test_matchers.cpp
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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 "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
#if defined(HAVE_OPENCV_XFEATURES2D) && defined(OPENCV_ENABLE_NONFREE)
|
||||
|
||||
TEST(SurfFeaturesFinder, CanFindInROIs)
|
||||
{
|
||||
Ptr<Feature2D> finder = xfeatures2d::SURF::create();
|
||||
Mat img = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/lena.png");
|
||||
|
||||
vector<Rect> rois;
|
||||
rois.push_back(Rect(0, 0, img.cols / 2, img.rows / 2));
|
||||
rois.push_back(Rect(img.cols / 2, img.rows / 2, img.cols - img.cols / 2, img.rows - img.rows / 2));
|
||||
|
||||
// construct mask
|
||||
Mat mask = Mat::zeros(img.size(), CV_8U);
|
||||
for (const Rect &roi : rois)
|
||||
{
|
||||
Mat(mask, roi) = 1;
|
||||
}
|
||||
|
||||
detail::ImageFeatures roi_features;
|
||||
detail::computeImageFeatures(finder, img, roi_features, mask);
|
||||
|
||||
int tl_rect_count = 0, br_rect_count = 0, bad_count = 0;
|
||||
for (const auto &keypoint : roi_features.keypoints)
|
||||
{
|
||||
if (rois[0].contains(keypoint.pt))
|
||||
tl_rect_count++;
|
||||
else if (rois[1].contains(keypoint.pt))
|
||||
br_rect_count++;
|
||||
else
|
||||
bad_count++;
|
||||
}
|
||||
|
||||
EXPECT_GT(tl_rect_count, 0);
|
||||
EXPECT_GT(br_rect_count, 0);
|
||||
EXPECT_EQ(bad_count, 0);
|
||||
}
|
||||
|
||||
#endif // HAVE_OPENCV_XFEATURES2D && OPENCV_ENABLE_NONFREE
|
||||
|
||||
TEST(ParallelFeaturesFinder, IsSameWithSerial)
|
||||
{
|
||||
Ptr<Feature2D> para_finder = ORB::create();
|
||||
Ptr<Feature2D> serial_finder = ORB::create();
|
||||
Mat img = imread(string(cvtest::TS::ptr()->get_data_path()) + "stitching/a3.png", IMREAD_GRAYSCALE);
|
||||
|
||||
detail::ImageFeatures serial_features;
|
||||
detail::computeImageFeatures(serial_finder, img, serial_features);
|
||||
|
||||
vector<Mat> imgs(50, img);
|
||||
vector<detail::ImageFeatures> para_features(imgs.size());
|
||||
detail::computeImageFeatures(para_finder, imgs, para_features); // FIXIT This call doesn't use parallel_for_()
|
||||
|
||||
// results must be the same
|
||||
Mat serial_descriptors;
|
||||
serial_features.descriptors.copyTo(serial_descriptors);
|
||||
for(size_t i = 0; i < para_features.size(); ++i)
|
||||
{
|
||||
SCOPED_TRACE(cv::format("i=%zu", i));
|
||||
EXPECT_EQ(serial_descriptors.size(), para_features[i].descriptors.size());
|
||||
#if 0 // FIXIT ORB descriptors are not bit-exact (perhaps due internal parallel_for usage)
|
||||
ASSERT_EQ(0, cv::norm(u_serial_descriptors, para_features[i].descriptors, NORM_L1))
|
||||
<< "serial_size=" << u_serial_descriptors.size()
|
||||
<< " par_size=" << para_features[i].descriptors.size()
|
||||
<< endl << u_serial_descriptors.getMat(ACCESS_READ)
|
||||
<< endl << endl << para_features[i].descriptors.getMat(ACCESS_READ);
|
||||
#endif
|
||||
EXPECT_EQ(serial_features.img_size, para_features[i].img_size);
|
||||
EXPECT_EQ(serial_features.keypoints.size(), para_features[i].keypoints.size());
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
18
3rdparty/opencv-4.5.4/modules/stitching/test/test_precomp.hpp
vendored
Normal file
18
3rdparty/opencv-4.5.4/modules/stitching/test/test_precomp.hpp
vendored
Normal file
@ -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_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
#include "opencv2/ts.hpp"
|
||||
#include "opencv2/stitching.hpp"
|
||||
#include "opencv2/stitching/detail/motion_estimators.hpp"
|
||||
#include "opencv2/stitching/detail/matchers.hpp"
|
||||
#include "opencv2/stitching/detail/blenders.hpp"
|
||||
#include "opencv2/stitching/detail/exposure_compensate.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_XFEATURES2D
|
||||
#include "opencv2/xfeatures2d/nonfree.hpp"
|
||||
#endif
|
||||
|
||||
#endif
|
131
3rdparty/opencv-4.5.4/modules/stitching/test/test_reprojection.cpp
vendored
Normal file
131
3rdparty/opencv-4.5.4/modules/stitching/test/test_reprojection.cpp
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
// 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 "test_precomp.hpp"
|
||||
#include "opencv2/stitching/warpers.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
class ReprojectionTest : public ::testing::Test {
|
||||
|
||||
protected:
|
||||
const size_t TEST_COUNT = 15;
|
||||
Mat K, R;
|
||||
RNG rng = RNG(0);
|
||||
ReprojectionTest()
|
||||
{
|
||||
K = Mat::eye(3, 3, CV_32FC1);
|
||||
float angle = (float)(30.0 * CV_PI / 180.0);
|
||||
float rotationMatrix[9] = {
|
||||
(float)cos(angle), (float)sin(angle), 0,
|
||||
(float)-sin(angle), (float)cos(angle), 0,
|
||||
0, 0, 1
|
||||
};
|
||||
Mat(3, 3, CV_32FC1, rotationMatrix).copyTo(R);
|
||||
}
|
||||
void TestReprojection(Ptr<detail::RotationWarper> warper, Point2f pt) {
|
||||
Point2f projected_pt = warper->warpPoint(pt, K, R);
|
||||
Point2f reprojected_pt = warper->warpPointBackward(projected_pt, K, R);
|
||||
EXPECT_NEAR(pt.x, reprojected_pt.x, float( 1e-5));
|
||||
EXPECT_NEAR(pt.y, reprojected_pt.y, float( 1e-5));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST_F(ReprojectionTest, PlaneWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<PlaneWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, AffineWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<AffineWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, CylindricalWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<CylindricalWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, SphericalWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<SphericalWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, FisheyeWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<FisheyeWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, StereographicWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<StereographicWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, CompressedRectilinearWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<CompressedRectilinearWarper>(1.5f, 1.0f);
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, CompressedRectilinearPortraitWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<CompressedRectilinearPortraitWarper>(1.5f, 1.0f);
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, PaniniWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<PaniniWarper>(1.5f, 1.0f);
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, PaniniPortraitWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<PaniniPortraitWarper>(1.5f, 1.0f);
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, MercatorWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<MercatorWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ReprojectionTest, TransverseMercatorWarper)
|
||||
{
|
||||
Ptr<WarperCreator> creator = makePtr<TransverseMercatorWarper>();
|
||||
for (size_t i = 0; i < TEST_COUNT; ++i) {
|
||||
TestReprojection(creator->create(1), Point2f(rng.uniform(-1.f, 1.f), rng.uniform(-1.f, 1.f)));
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
28
3rdparty/opencv-4.5.4/modules/stitching/test/test_stitcher.cpp
vendored
Normal file
28
3rdparty/opencv-4.5.4/modules/stitching/test/test_stitcher.cpp
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// 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 "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
TEST(ImageStitcher, setTransform)
|
||||
{
|
||||
vector<Mat> images;
|
||||
images.push_back(imread(string(cvtest::TS::ptr()->get_data_path()) + "stitching/s1.jpg"));
|
||||
images.push_back(imread(string(cvtest::TS::ptr()->get_data_path()) + "stitching/s2.jpg"));
|
||||
|
||||
Mat expected;
|
||||
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);
|
||||
EXPECT_TRUE(Stitcher::OK == stitcher->estimateTransform(images));
|
||||
EXPECT_TRUE(Stitcher::OK == stitcher->composePanorama(expected));
|
||||
|
||||
Mat result;
|
||||
Ptr<Stitcher> another_stitcher = Stitcher::create(Stitcher::PANORAMA);
|
||||
EXPECT_TRUE(Stitcher::OK == another_stitcher->setTransform(images, stitcher->cameras()));
|
||||
EXPECT_TRUE(Stitcher::OK == another_stitcher->composePanorama(result));
|
||||
|
||||
EXPECT_DOUBLE_EQ(cvtest::norm(expected, result, NORM_INF), .0);
|
||||
}
|
||||
|
||||
}} // namespace opencv_test
|
50
3rdparty/opencv-4.5.4/modules/stitching/test/test_wave_correction.cpp
vendored
Normal file
50
3rdparty/opencv-4.5.4/modules/stitching/test/test_wave_correction.cpp
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// 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 "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
namespace {
|
||||
|
||||
detail::WaveCorrectKind correctionKind(const std::vector<UMat>& images)
|
||||
{
|
||||
|
||||
Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);
|
||||
stitcher->estimateTransform(images);
|
||||
|
||||
std::vector<Mat> rmats;
|
||||
auto cameras = stitcher->cameras();
|
||||
for (const auto& camera: cameras)
|
||||
rmats.push_back(camera.R);
|
||||
|
||||
return detail::autoDetectWaveCorrectKind(rmats);
|
||||
}
|
||||
|
||||
TEST(WaveCorrection, AutoWaveCorrection)
|
||||
{
|
||||
std::vector<UMat> images(2);
|
||||
imread(cvtest::TS::ptr()->get_data_path() + "stitching/s1.jpg").copyTo(images[0]);
|
||||
imread(cvtest::TS::ptr()->get_data_path() + "stitching/s2.jpg").copyTo(images[1]);
|
||||
|
||||
EXPECT_EQ(detail::WAVE_CORRECT_HORIZ, correctionKind(images));
|
||||
|
||||
std::vector<UMat> rotated_images(2);
|
||||
rotate(images[0], rotated_images[0], cv::ROTATE_90_CLOCKWISE);
|
||||
rotate(images[1], rotated_images[1], cv::ROTATE_90_CLOCKWISE);
|
||||
|
||||
EXPECT_EQ(detail::WAVE_CORRECT_VERT, correctionKind(rotated_images));
|
||||
|
||||
rotate(images[0], rotated_images[0], cv::ROTATE_90_COUNTERCLOCKWISE);
|
||||
rotate(images[1], rotated_images[1], cv::ROTATE_90_COUNTERCLOCKWISE);
|
||||
|
||||
EXPECT_EQ(detail::WAVE_CORRECT_VERT, correctionKind(rotated_images));
|
||||
|
||||
rotate(images[0], rotated_images[0], cv::ROTATE_180);
|
||||
rotate(images[1], rotated_images[1], cv::ROTATE_180);
|
||||
|
||||
EXPECT_EQ(detail::WAVE_CORRECT_HORIZ, correctionKind(rotated_images));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opencv_test
|
Reference in New Issue
Block a user