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: