全景视频拼接(三):将视频转换为图像序列(有顺序的)

时间:2023-02-01 22:16:03

项目要求:利用双摄像头同时采集两个视频,离线拼接,将两个视频拼接成一个视频。

该部分代码实现功能:

将视频转换为图像序列(有顺序的)

 代码:

 
//双目摄像头
//询问拍摄多久的视频,以秒为单位计算
//获取相应时间的视频
//将对应时间的视频,以每帧存储图像

#include<iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main() 
{    
    

    VideoCapture cap00("..\\video\\103_fmlaf\\two_test0.avi");   
    VideoCapture cap11("..\\video\\103_fmlaf\\two_test1.avi"); 
    if(cap00.isOpened() && cap11.isOpened())    
        cout << "ok ,have a video" << endl;    
    else   
        cout << "no video" << endl;  
  
  
    Mat frame00,frame11;     
    string src_image_namea = "..\\pic_a\\105_fmlaf_pica\\";  
    const int num00 = 500;    
    char num[num00],num1[4] = "1(",num2[6] = ")";  
    string num3 = ".jpg"; 
    int numbera = 1;
    for (int i = 1; ;i++)    
    {   
	itoa(i, num, 10);
        cap00 >> frame00;    
        if(frame00.empty())    
              break;  
	imwrite(src_image_namea+num1+num+num2+num3,frame00);
		
       }    
    cap00.release();   
  
    //重复上一步骤  

     string src_image_nameb =  "..\\pic_b\\105_fmlaf_picb\\";
    const int num11 = 500;    
    char numb[num11],num1b[4] = "1(",num2b[6] = ")";  
    string num3b = ".jpg"; 
    for (int i = 1; ;i++)    
    {   
	itoa(i, numb, 10);
        cap11 >> frame11;    
        if(frame11.empty())    
              break;  
		 
	cout <<"b"<< endl;
	imwrite(src_image_nameb+num1b+numb+num2b+num3b,frame11);
       }    
        cap11.release();   
        system("pause");    
    
        return 0;    
    
}