使用下面的代码:
#include <opencv2/opencv.hpp>
#include <opencv2/stitching/stitcher.hpp>
#include <iostream>
#include <vector>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
Mat fr1, fr2, pano;
bool try_use_gpu = false;
vector<Mat> imgs;
VideoCapture cap(0), cap2(1);
while (true)
{
cap >> fr1;
cap2 >> fr2;
imgs.push_back(fr1.clone());
imgs.push_back(fr2.clone());
Stitcher test = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = test.stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Error stitching - Code: " <<int(status)<<endl;
return -1;
}
imshow("Frame 1", fr1);
imshow("Frame 2", fr2);
imshow("Stitched Image", pano);
if(waitKey(30) >= 0)
break;
}
return 0;
}
此代码会抛出 1 的状态错误。我不知道这意味着什么,也不知道为什么这件事很难处理网络摄像头的馈送。怎么了?
-托尼