0

我正在尝试找到一种方法来在对象周围不同位置的多个摄像机之间切换,以使用 C++ 实时获得 360 度视图。我正在使用opencv,我成功打开了所有的摄像头,但我找不到文档或360度流畅开关的方法。

这是我到目前为止所做的代码

 using namespace cv;
 using namespace std;


 int main(int argc, char* argv[])
 {


  int a = 0;
VideoCapture cap(0); // open the video camera no. 0
VideoCapture cap1(1);

//if (!cap.isOpened())  // if not success, exit program
//{
//  cout << "Cannot open the video cam" << endl;
//  return -1; 
//}

double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video

cout << "Frame size : " << dWidth << " x " << dHeight << endl;

namedWindow("MyVideo", CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"

while (1)
{
    Mat frame;

    bool bSuccess;
    if(a==0)
        bSuccess = cap.read(frame); // read a new frame from video
    else if (a == 1)
        bSuccess = cap1.read(frame);

    if (!bSuccess) //if not success, break loop
    {
        cout << "Cannot read a frame from video stream" << endl;
        break;
    }

    imshow("MyVideo", frame); //show the frame in "MyVideo" window

    if (waitKey(1) == 'a')
    {
        if (!a) a = 1;
        else a = 0;
    }
    /*else if (waitKey(1) == 27)
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }

我有 6 个其他相机,中间的一个对象可以用 C++ 完成吗?还是我需要使用其他东西。请记住,它必须实时完成。

4

0 回答 0