mirror of
https://github.com/opencv/opencv.git
synced 2024-12-02 16:00:17 +08:00
5f20e802d2
[GSOC] Speeding-up AKAZE, part #1 (#8869)
* ts: expand arguments before stringifications in CV_ENUM and CV_FLAGS
added protective macros to always force macro expansion of arguments. This allows using CV_ENUM and CV_FLAGS with macro arguments.
* feature2d: unify perf test
use the same test for all detectors/descriptors we have.
* added AKAZE tests
* features2d: extend perf tests
* add BRISK, KAZE, MSER
* run all extract tests on AKAZE keypoints, so that the test si more comparable for the speed of extraction
* feature2d: rework opencl perf tests
use the same configuration as cpu tests
* feature2d: fix descriptors allocation for AKAZE and KAZE
fix crash when descriptors are UMat
* feature2d: name enum to fix build with older gcc
* Revert "ts: expand arguments before stringifications in CV_ENUM and CV_FLAGS"
This reverts commit 19538cac1e
.
This wasn't a great idea after all. There is a lot of flags implemented as #define, that we don't want to expand.
* feature2d: fix expansion problems with CV_ENUM in perf
* expand arguments before passing them to CV_ENUM. This does not need modifications of CV_ENUM.
* added include guards to `perf_feature2d.hpp`
* feature2d: fix crash in AKAZE when using KAZE descriptors
* out-of-bound access in Get_MSURF_Descriptor_64
* this happened reliably when running on provided keypoints (not computed by the same instance)
* feature2d: added regression tests for AKAZE
* test with both MLDB and KAZE keypoints
* feature2d: do not compute keypoints orientation twice
* always compute keypoints orientation, when computing keypoints
* do not recompute keypoint orientation when computing descriptors
this allows to test detection and extraction separately
* features2d: fix crash in AKAZE
* out-of-bound reads near the image edge
* same as the bug in KAZE descriptors
* feature2d: refactor invariance testing
* split detectors and descriptors tests
* rewrite to google test to simplify debugging
* add tests for AKAZE and one test for ORB
* stitching: add tests with AKAZE feature finder
* added basic stitching cpu and ocl tests
* fix bug in AKAZE wrapper for stitching pipeline causing lots of
! OPENCV warning: getUMat()/getMat() call chain possible problem.
! Base object is dead, while nested/derived object is still alive or processed.
! Please check lifetime of UMat/Mat objects!
144 lines
4.4 KiB
C++
144 lines
4.4 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) 2014, Itseez, Inc, all rights reserved.
|
|
|
|
#include "../perf_precomp.hpp"
|
|
#include "opencv2/ts/ocl_perf.hpp"
|
|
|
|
#ifdef HAVE_OPENCL
|
|
|
|
namespace cvtest {
|
|
namespace ocl {
|
|
|
|
using namespace cv;
|
|
using namespace perf;
|
|
using namespace std;
|
|
using namespace std::tr1;
|
|
|
|
#define SURF_MATCH_CONFIDENCE 0.65f
|
|
#define ORB_MATCH_CONFIDENCE 0.3f
|
|
#define WORK_MEGAPIX 0.6
|
|
|
|
typedef TestBaseWithParam<string> stitch;
|
|
|
|
#ifdef HAVE_OPENCV_XFEATURES2D
|
|
#define TEST_DETECTORS testing::Values("surf", "orb", "akaze")
|
|
#else
|
|
#define TEST_DETECTORS testing::Values("orb", "akaze")
|
|
#endif
|
|
|
|
OCL_PERF_TEST_P(stitch, a123, TEST_DETECTORS)
|
|
{
|
|
UMat pano;
|
|
|
|
vector<Mat> _imgs;
|
|
_imgs.push_back( imread( getDataPath("stitching/a1.png") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/a2.png") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/a3.png") ) );
|
|
vector<UMat> imgs = ToUMat(_imgs);
|
|
|
|
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
|
|
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
|
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
|
|
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
|
|
|
|
declare.iterations(20);
|
|
|
|
while(next())
|
|
{
|
|
Stitcher stitcher = Stitcher::createDefault();
|
|
stitcher.setFeaturesFinder(featuresFinder);
|
|
stitcher.setFeaturesMatcher(featuresMatcher);
|
|
stitcher.setWarper(makePtr<SphericalWarper>());
|
|
stitcher.setRegistrationResol(WORK_MEGAPIX);
|
|
|
|
startTimer();
|
|
stitcher.stitch(imgs, pano);
|
|
stopTimer();
|
|
}
|
|
|
|
EXPECT_NEAR(pano.size().width, 1182, 50);
|
|
EXPECT_NEAR(pano.size().height, 682, 30);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
OCL_PERF_TEST_P(stitch, b12, TEST_DETECTORS)
|
|
{
|
|
UMat pano;
|
|
|
|
vector<Mat> imgs;
|
|
imgs.push_back( imread( getDataPath("stitching/b1.png") ) );
|
|
imgs.push_back( imread( getDataPath("stitching/b2.png") ) );
|
|
|
|
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
|
|
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
|
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
|
|
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
|
|
|
|
declare.iterations(20);
|
|
|
|
while(next())
|
|
{
|
|
Stitcher stitcher = Stitcher::createDefault();
|
|
stitcher.setFeaturesFinder(featuresFinder);
|
|
stitcher.setFeaturesMatcher(featuresMatcher);
|
|
stitcher.setWarper(makePtr<SphericalWarper>());
|
|
stitcher.setRegistrationResol(WORK_MEGAPIX);
|
|
|
|
startTimer();
|
|
stitcher.stitch(imgs, pano);
|
|
stopTimer();
|
|
}
|
|
|
|
EXPECT_NEAR(pano.size().width, 1124, 50);
|
|
EXPECT_NEAR(pano.size().height, 644, 30);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
OCL_PERF_TEST_P(stitch, boat, TEST_DETECTORS)
|
|
{
|
|
UMat pano;
|
|
|
|
vector<Mat> _imgs;
|
|
_imgs.push_back( imread( getDataPath("stitching/boat1.jpg") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/boat2.jpg") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/boat3.jpg") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/boat4.jpg") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/boat5.jpg") ) );
|
|
_imgs.push_back( imread( getDataPath("stitching/boat6.jpg") ) );
|
|
vector<UMat> imgs = ToUMat(_imgs);
|
|
|
|
Ptr<detail::FeaturesFinder> featuresFinder = getFeatureFinder(GetParam());
|
|
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
|
? makePtr<detail::BestOf2NearestMatcher>(false, ORB_MATCH_CONFIDENCE)
|
|
: makePtr<detail::BestOf2NearestMatcher>(false, SURF_MATCH_CONFIDENCE);
|
|
|
|
declare.iterations(20);
|
|
|
|
while(next())
|
|
{
|
|
Stitcher stitcher = Stitcher::createDefault();
|
|
stitcher.setFeaturesFinder(featuresFinder);
|
|
stitcher.setFeaturesMatcher(featuresMatcher);
|
|
stitcher.setWarper(makePtr<SphericalWarper>());
|
|
stitcher.setRegistrationResol(WORK_MEGAPIX);
|
|
|
|
startTimer();
|
|
stitcher.stitch(imgs, pano);
|
|
stopTimer();
|
|
}
|
|
|
|
EXPECT_NEAR(pano.size().width, 10789, 200);
|
|
EXPECT_NEAR(pano.size().height, 2663, 100);
|
|
|
|
SANITY_CHECK_NOTHING();
|
|
}
|
|
|
|
} } // namespace cvtest::ocl
|
|
|
|
#endif // HAVE_OPENCL
|