-
-
Save abram/a4c645ccbcaa1f332485a8cc6c0be4c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <opencv2/imgcodecs.hpp> | |
#include <opencv2/opencv_modules.hpp> | |
#include <opencv2/stitching.hpp> | |
#include <opencv2/stitching/detail/warpers.hpp> | |
using namespace std; | |
using namespace cv; | |
using namespace cv::detail; | |
int main(int argc, char* argv[]) { | |
int imageCount = argc - 2; | |
if (imageCount < 2) { | |
cout << argv[0] << " <image1> <image2> ... <imageN> <output path>"; | |
return -1; | |
} | |
vector<Mat> images(imageCount); | |
for (int i = 0; i < imageCount; ++i) { | |
Mat image = imread(argv[i + 1]); | |
if (image.empty()) { | |
cout << "Error opening image " << argv[i] << "\n"; | |
return -1; | |
} | |
cout << "Loading image: " << argv[i + 1] << "\n"; | |
images[i] = image.clone(); | |
} | |
Stitcher stitcher = Stitcher::createDefault(true); | |
stitcher.setRegistrationResol(1.5); | |
stitcher.setSeamEstimationResol(0.3); | |
stitcher.setCompositingResol(2.0); | |
stitcher.setPanoConfidenceThresh(0.4); | |
stitcher.setWarper(makePtr<cv::CylindricalWarper>()); | |
stitcher.setSeamFinder(makePtr<detail::VoronoiSeamFinder>()); | |
stitcher.setFeaturesFinder(makePtr<detail::SurfFeaturesFinder>()); | |
Mat result; | |
stitcher.stitch(images, result); | |
cout << "Saving file: " << argv[argc - 1] << "\n"; | |
imwrite(argv[argc - 1], result); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment