Tegra-optimized features matching for Stitching
This commit is contained in:
parent
5afb445283
commit
b720eddd9e
@ -1,4 +1,3 @@
|
|||||||
include_directories("${OpenCV_SOURCE_DIR}/modules/imgproc/src") # For gcgraph.hpp
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
define_opencv_module(stitching opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_flann opencv_objdetect)
|
define_opencv_module(stitching opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_flann opencv_objdetect)
|
||||||
else()
|
else()
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
#include "perf_precomp.hpp"
|
#include "perf_precomp.hpp"
|
||||||
|
|
||||||
#include "opencv2/highgui/highgui.hpp"
|
#include "opencv2/highgui/highgui.hpp"
|
||||||
|
#include "opencv2/flann/flann.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace perf;
|
using namespace perf;
|
||||||
|
|
||||||
|
#define SURF_MATCH_CONFIDENCE 0.65f
|
||||||
|
#define ORB_MATCH_CONFIDENCE 0.3f
|
||||||
|
#define WORK_MEGAPIX 0.6
|
||||||
|
|
||||||
typedef TestBaseWithParam<String> stitch;
|
typedef TestBaseWithParam<String> stitch;
|
||||||
|
typedef TestBaseWithParam<String> match;
|
||||||
|
|
||||||
PERF_TEST_P( stitch, a123, testing::Values("surf", "orb"))
|
PERF_TEST_P( stitch, a123, testing::Values("surf", "orb"))
|
||||||
{
|
{
|
||||||
@ -23,8 +29,8 @@ PERF_TEST_P( stitch, a123, testing::Values("surf", "orb"))
|
|||||||
: (detail::FeaturesFinder*)new detail::SurfFeaturesFinder();
|
: (detail::FeaturesFinder*)new detail::SurfFeaturesFinder();
|
||||||
|
|
||||||
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
||||||
? new detail::BestOf2NearestMatcher(false, 0.3f)
|
? new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE)
|
||||||
: new detail::BestOf2NearestMatcher(false, 0.65f);
|
: new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE);
|
||||||
|
|
||||||
declare.time(30 * 20).iterations(50);
|
declare.time(30 * 20).iterations(50);
|
||||||
|
|
||||||
@ -33,6 +39,8 @@ PERF_TEST_P( stitch, a123, testing::Values("surf", "orb"))
|
|||||||
Stitcher stitcher = Stitcher::createDefault();
|
Stitcher stitcher = Stitcher::createDefault();
|
||||||
stitcher.setFeaturesFinder(featuresFinder);
|
stitcher.setFeaturesFinder(featuresFinder);
|
||||||
stitcher.setFeaturesMatcher(featuresMatcher);
|
stitcher.setFeaturesMatcher(featuresMatcher);
|
||||||
|
stitcher.setWarper(new CylindricalWarper());
|
||||||
|
stitcher.setRegistrationResol(WORK_MEGAPIX);
|
||||||
|
|
||||||
startTimer();
|
startTimer();
|
||||||
status = stitcher.stitch(imgs, pano);
|
status = stitcher.stitch(imgs, pano);
|
||||||
@ -54,8 +62,8 @@ PERF_TEST_P( stitch, b12, testing::Values("surf", "orb"))
|
|||||||
: (detail::FeaturesFinder*)new detail::SurfFeaturesFinder();
|
: (detail::FeaturesFinder*)new detail::SurfFeaturesFinder();
|
||||||
|
|
||||||
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
Ptr<detail::FeaturesMatcher> featuresMatcher = GetParam() == "orb"
|
||||||
? new detail::BestOf2NearestMatcher(false, 0.3f)
|
? new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE)
|
||||||
: new detail::BestOf2NearestMatcher(false, 0.65f);
|
: new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE);
|
||||||
|
|
||||||
declare.time(30 * 20).iterations(50);
|
declare.time(30 * 20).iterations(50);
|
||||||
|
|
||||||
@ -64,9 +72,56 @@ PERF_TEST_P( stitch, b12, testing::Values("surf", "orb"))
|
|||||||
Stitcher stitcher = Stitcher::createDefault();
|
Stitcher stitcher = Stitcher::createDefault();
|
||||||
stitcher.setFeaturesFinder(featuresFinder);
|
stitcher.setFeaturesFinder(featuresFinder);
|
||||||
stitcher.setFeaturesMatcher(featuresMatcher);
|
stitcher.setFeaturesMatcher(featuresMatcher);
|
||||||
|
stitcher.setWarper(new CylindricalWarper());
|
||||||
|
stitcher.setRegistrationResol(WORK_MEGAPIX);
|
||||||
|
|
||||||
startTimer();
|
startTimer();
|
||||||
status = stitcher.stitch(imgs, pano);
|
status = stitcher.stitch(imgs, pano);
|
||||||
stopTimer();
|
stopTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PERF_TEST_P( match, bestOf2Nearest, testing::Values("surf", "orb"))
|
||||||
|
{
|
||||||
|
Mat img1, img1_full = imread( getDataPath("stitching/b1.jpg") );
|
||||||
|
Mat img2, img2_full = imread( getDataPath("stitching/b2.jpg") );
|
||||||
|
float scale1 = std::min(1.0, sqrt(WORK_MEGAPIX * 1e6 / img1_full.total()));
|
||||||
|
float scale2 = std::min(1.0, sqrt(WORK_MEGAPIX * 1e6 / img2_full.total()));
|
||||||
|
resize(img1_full, img1, Size(), scale1, scale1);
|
||||||
|
resize(img2_full, img2, Size(), scale2, scale2);
|
||||||
|
|
||||||
|
Ptr<detail::FeaturesFinder> finder;
|
||||||
|
Ptr<detail::FeaturesMatcher> matcher;
|
||||||
|
if (GetParam() == "surf")
|
||||||
|
{
|
||||||
|
finder = new detail::SurfFeaturesFinder();
|
||||||
|
matcher = new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE);
|
||||||
|
}
|
||||||
|
else if (GetParam() == "orb")
|
||||||
|
{
|
||||||
|
finder = new detail::OrbFeaturesFinder();
|
||||||
|
matcher = new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FAIL() << "Unknown 2D features type: " << GetParam();
|
||||||
|
}
|
||||||
|
|
||||||
|
detail::ImageFeatures features1, features2;
|
||||||
|
(*finder)(img1, features1);
|
||||||
|
(*finder)(img2, features2);
|
||||||
|
|
||||||
|
detail::MatchesInfo pairwise_matches;
|
||||||
|
|
||||||
|
declare.in(features1.descriptors, features2.descriptors)
|
||||||
|
.iterations(100);
|
||||||
|
|
||||||
|
while(next())
|
||||||
|
{
|
||||||
|
cvflann::seed_random(42);//for predictive FlannBasedMatcher
|
||||||
|
startTimer();
|
||||||
|
(*matcher)(features1, features2, pairwise_matches);
|
||||||
|
stopTimer();
|
||||||
|
matcher->collectGarbage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -147,11 +147,16 @@ private:
|
|||||||
|
|
||||||
void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
||||||
{
|
{
|
||||||
matches_info.matches.clear();
|
|
||||||
|
|
||||||
CV_Assert(features1.descriptors.type() == features2.descriptors.type());
|
CV_Assert(features1.descriptors.type() == features2.descriptors.type());
|
||||||
CV_Assert(features2.descriptors.depth() == CV_8U || features2.descriptors.depth() == CV_32F);
|
CV_Assert(features2.descriptors.depth() == CV_8U || features2.descriptors.depth() == CV_32F);
|
||||||
|
|
||||||
|
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||||
|
if (tegra::match2nearest(features1, features2, matches_info, match_conf_))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
matches_info.matches.clear();
|
||||||
|
|
||||||
Ptr<flann::IndexParams> indexParams = new flann::KDTreeIndexParams();
|
Ptr<flann::IndexParams> indexParams = new flann::KDTreeIndexParams();
|
||||||
Ptr<flann::SearchParams> searchParams = new flann::SearchParams();
|
Ptr<flann::SearchParams> searchParams = new flann::SearchParams();
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include "opencv2/core/core.hpp"
|
||||||
|
#include "opencv2/core/internal.hpp"
|
||||||
#include "opencv2/stitching/stitcher.hpp"
|
#include "opencv2/stitching/stitcher.hpp"
|
||||||
#include "opencv2/stitching/detail/autocalib.hpp"
|
#include "opencv2/stitching/detail/autocalib.hpp"
|
||||||
#include "opencv2/stitching/detail/blenders.hpp"
|
#include "opencv2/stitching/detail/blenders.hpp"
|
||||||
@ -64,14 +66,17 @@
|
|||||||
#include "opencv2/stitching/detail/seam_finders.hpp"
|
#include "opencv2/stitching/detail/seam_finders.hpp"
|
||||||
#include "opencv2/stitching/detail/util.hpp"
|
#include "opencv2/stitching/detail/util.hpp"
|
||||||
#include "opencv2/stitching/detail/warpers.hpp"
|
#include "opencv2/stitching/detail/warpers.hpp"
|
||||||
#include "opencv2/core/core.hpp"
|
|
||||||
#include "opencv2/core/internal.hpp"
|
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/features2d/features2d.hpp"
|
#include "opencv2/features2d/features2d.hpp"
|
||||||
#include "opencv2/calib3d/calib3d.hpp"
|
#include "opencv2/calib3d/calib3d.hpp"
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
# include "opencv2/gpu/gpu.hpp"
|
# include "opencv2/gpu/gpu.hpp"
|
||||||
#endif
|
#endif
|
||||||
#include "gcgraph.hpp"
|
|
||||||
|
#include "modules/imgproc/src/gcgraph.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||||
|
# include "opencv2/stitching/stitching_tegra.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user