OPENCV uses stitcher-type image stitching to generate panoramic images __stitcher

Source: Internet
Author: User

OpenCV in the Stitcher class can achieve panoramic image, the effect is good. The example below is a simplification of the stitching.cpp in OpenCV samples, which can be found in this path:

\opencv\sources\samples\cpp\stitching.cpp


 #include <fstream> #include "opencv2/highgui/highgui.hpp" #include "opencv2/stitching/
Stitcher.hpp "#include <iostream> using namespace CV;

using namespace Std; Vector<mat> IMGs;

Save stitching original image vector//import all original mosaic image function void Parsecmdargs (int argc, char** argv);	
	int main (int argc, char* argv[]) {//import mosaic image Parsecmdargs (argc, argv);
	Mat Pano;
	Stitcher Stitcher = Stitcher::createdefault (false); Stitcher::status Status = Stitcher.stitch (IMGs, Pano);//stitching if (Status!= Stitcher::ok)//Judging whether the stitching is successful {cout << "Can
		' t stitch images, error code = ' << int (status) << Endl;
	return-1;
	} namedwindow ("Panorama stitching", 0);
	Imshow ("Panoramic stitching", pano);
	Imwrite ("d:\\ panoramic mosaic. jpg", pano);   
	Waitkey ();
return 0;
		//Import all original mosaic image functions void Parsecmdargs (int argc, char** argv) {for (int i=1;i<argc;i++) {Mat img = imread (argv[i));
		if (Img.empty ()) {cout << "Can ' t read image '" << argv[i] << "\ n";
	Imgs.push_back (IMG); }
}


Figure 1:


Figure 2:


Figure 3:


Figure 4:


Figure 5:



5 pictures of the shooting angle together around 180°, not compressed, download can be directly tested using, incoming order random, Stitcher will automatically arrange. Panoramic stitching effect is very good:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.