Merge pull request #12827 from hrnr:stitching_4

[evolution] Stitching for OpenCV 4.0

* stitching: wrap Stitcher::create for bindings

* provide method for consistent stitcher usage across languages

* samples: add python stitching sample

* port cpp stitching sample to python

* stitching: consolidate Stitcher create methods

* remove Stitcher::createDefault, it returns Stitcher, not Ptr<Stitcher> -> inconsistent API
* deprecate cv::createStitcher and cv::createStitcherScans in favor of Stitcher::create

* stitching: avoid anonymous enum in Stitcher

* ORIG_RESOL should be double
* add documentatiton

* stitching: improve documentation in Stitcher

* stitching: expose estimator in Stitcher

* remove ABI hack

* stitching: drop try_use_gpu flag

* OCL will be used automatically through T-API in OCL-enable paths
* CUDA won't be used unless user sets CUDA-enabled classes manually

* stitching: drop FeaturesFinder

* use Feature2D instead of FeaturesFinder
* interoperability with features2d module
* detach from dependency on xfeatures2d

* features2d: fix compute and detect to work with UMat vectors

* correctly pass UMats as UMats to allow OCL paths
* support vector of UMats as output arg

* stitching: use nearest interpolation for resizing masks

* fix warnings
This commit is contained in:
Jiri Horner
2018-11-10 17:53:48 +01:00
committed by Alexander Alekhin
parent be9b676db3
commit 1ba7c728a6
18 changed files with 329 additions and 810 deletions
+1 -18
View File
@@ -8,7 +8,6 @@
using namespace std;
using namespace cv;
bool try_use_gpu = false;
bool divide_images = false;
Stitcher::Mode mode = Stitcher::PANORAMA;
vector<Mat> imgs;
@@ -24,7 +23,7 @@ int main(int argc, char* argv[])
//![stitching]
Mat pano;
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Ptr<Stitcher> stitcher = Stitcher::create(mode);
Stitcher::Status status = stitcher->stitch(imgs, pano);
if (status != Stitcher::OK)
@@ -47,9 +46,6 @@ void printUsage(char** argv)
"Flags:\n"
" --d3\n"
" internally creates three chunks of each image to increase stitching success\n"
" --try_use_gpu (yes|no)\n"
" Try to use GPU. The default value is 'no'. All default values\n"
" are for CPU mode.\n"
" --mode (panorama|scans)\n"
" Determines configuration of stitcher. The default is 'panorama',\n"
" mode suitable for creating photo panoramas. Option 'scans' is suitable\n"
@@ -75,19 +71,6 @@ int parseCmdArgs(int argc, char** argv)
printUsage(argv);
return EXIT_FAILURE;
}
else if (string(argv[i]) == "--try_use_gpu")
{
if (string(argv[i + 1]) == "no")
try_use_gpu = false;
else if (string(argv[i + 1]) == "yes")
try_use_gpu = true;
else
{
cout << "Bad --try_use_gpu flag value\n";
return EXIT_FAILURE;
}
i++;
}
else if (string(argv[i]) == "--d3")
{
divide_images = true;
+13 -13
View File
@@ -17,6 +17,10 @@
#include "opencv2/stitching/detail/warpers.hpp"
#include "opencv2/stitching/warpers.hpp"
#ifdef HAVE_OPENCV_XFEATURES2D
#include "opencv2/xfeatures2d/nonfree.hpp"
#endif
#define ENABLE_LOG 1
#define LOG(msg) std::cout << msg
#define LOGLN(msg) std::cout << msg << std::endl
@@ -374,23 +378,20 @@ int main(int argc, char* argv[])
int64 t = getTickCount();
#endif
Ptr<FeaturesFinder> finder;
if (features_type == "surf")
Ptr<Feature2D> finder;
if (features_type == "orb")
{
#ifdef HAVE_OPENCV_XFEATURES2D
if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0)
finder = makePtr<SurfFeaturesFinderGpu>();
else
#endif
finder = makePtr<SurfFeaturesFinder>();
finder = ORB::create();
}
else if (features_type == "orb")
#ifdef HAVE_OPENCV_XFEATURES2D
else if (features_type == "surf")
{
finder = makePtr<OrbFeaturesFinder>();
finder = xfeatures2d::SURF::create();
}
else if (features_type == "sift") {
finder = makePtr<SiftFeaturesFinder>();
finder = xfeatures2d::SIFT::create();
}
#endif
else
{
cout << "Unknown 2D features type: '" << features_type << "'.\n";
@@ -435,7 +436,7 @@ int main(int argc, char* argv[])
is_seam_scale_set = true;
}
(*finder)(img, features[i]);
computeImageFeatures(finder, img, features[i]);
features[i].img_idx = i;
LOGLN("Features in image #" << i+1 << ": " << features[i].keypoints.size());
@@ -443,7 +444,6 @@ int main(int argc, char* argv[])
images[i] = img.clone();
}
finder->collectGarbage();
full_img.release();
img.release();