Sie sind auf Seite 1von 2

#include

#include
#include
#include
#include

<iostream>
<fstream>
"opencv2/imgcodecs.hpp"
"opencv2/highgui/highgui.hpp"
"opencv2/stitching.hpp"

using namespace std;


using namespace cv;
bool try_use_gpu = true;
Stitcher::Mode mode = Stitcher::PANORAMA;
vector<Mat> imgs;
string result_name = "abmks.jpg";
int main(int argc, char* argv[])
{
VideoCapture cap1("C:/Users/Austin/Desktop/xxx.avi"); // open the video
file for reading
VideoCapture cap2("C:/Users/Austin/Desktop/xx.avi");
VideoCapture cap3("C:/Users/Austin/Desktop/x.avi");
double fps1 = cap1.get(CV_CAP_PROP_FPS); //get the frames per seconds of
the video
double fps2 = cap2.get(CV_CAP_PROP_FPS);
double fps3 = cap3.get(CV_CAP_PROP_FPS);
//namedWindow("MyVideo1", CV_WINDOW_AUTOSIZE); //create a window called
"MyVideo"
//namedWindow("MyVideo2", CV_WINDOW_AUTOSIZE);
double dWidth = cap1.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of fr
ames of the video
double dHeight = cap1.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of
frames of the video
//printf("%lf , %lf", dWidth, dHeight);
Size frameSize(720,480);
VideoWriter oVideoWriter("D:/MyVideo3.avi", CV_FOURCC('P', 'I', 'M', '1'
), 24, frameSize, true); //initialize the VideoWriter object
while (1)
{
Mat frame1;
Mat frame2;
Mat frame3;
bool bSuccess1 = cap1.read(frame1); // read a new frame from vid
eo
bool bSuccess2 = cap2.read(frame2);
bool bSuccess3 = cap3.read(frame3);
/*if (!bSuccess1) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}*/
//imshow("MyVideo1", frame1);
//imshow("MyVideo2", frame2);//show the frame in "MyVideo" windo
w
//waitKey(100);

Mat img = frame1;


/*if (img.empty())
{
cout << "Can't read image1 \n";
return -1;
}*/
imgs.push_back(img);
Mat img1 = frame2;
/*if (img.empty())
{
cout << "Can't read image \n";
return -1;
}*/
imgs.push_back(img1);
Mat img2 = frame3;
/*if (img.empty())
{
cout << "Can't read image1 \n";
return -1;
}*/
imgs.push_back(img2);
//namedWindow("MyVideo1", CV_WINDOW_AUTOSIZE);
Mat pano;
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(imgs, pano);
/*
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << e
ndl;
return -1;
}*/
Size size(720, 480);//the dst image size,e.g.100x100
resize(pano, pano, size);
//imwrite(result_name, pano);
oVideoWriter.write(pano);
//namedWindow("MyVideo1", CV_WINDOW_AUTOSIZE);
imwrite("xxx.jpg", pano);
printf(":\n");
//imshow("MyVideo1", pano);
waitKey(10);
destroyAllWindows();
/*if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. I
f 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}*/
}
return 0;
}

Das könnte Ihnen auch gefallen