在QT中显示多个OpenCV VideoCapture对象

时间:2016-01-18 00:39:20

标签: c++ qt opencv

我从两个树莓皮中捕获网络摄像头流,我试图在两个流上进行一些图像处理。我有两个Q标签,我试图用来显示来自pis的图像。然而,当一个流实时显示时,另一个流有4-5秒的延迟。如果我尝试在两个Qlabel对象上显示一个流,则会出现相同的结果。这是一个线程问题吗?你能帮忙吗?

VideoCapture capWebcam;
VideoCapture EyeintheSky;
Mat matEyeInTheSky;
QImage qimgEyeInTheSky;
Mat matOriginal;
QImage qimgOriginal;

 MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
      ui->setupUi(this);

   capWebcam.open("http://192.168.0.102:8080/?action=stream?dummy=param.mjpg"); //from MJPG STreamer image processing

  EyeintheSky.open("http://192.168.0.100:8080/?action=stream?dummy=param.mjpg");

   if (capWebcam.isOpened() == false) {
      return;
      }

   if(EyeintheSky.isOpened() == false) {
    return;
     }
}

void MainWindow::processFrameAndUpdateGUI() {

capWebcam.read(matOriginal);
EyeintheSky.read(matEyeInTheSky);

if(matOriginal.empty() == true) {
    qDebug() << "Empty Picture";
    return;
}
else {
   //  start of visual processing

    // Output Tri Track images to screen
    // map QImage to QLabel
    cvtColor(matOriginal,matOriginal,COLOR_BGR2RGB);
    QImage qimgOriginal((uchar*)matOriginal.data,matOriginal.cols,matOriginal.rows, matOriginal.step,QImage::Format_RGB888);
    ui->lblInputImage->setPixmap(QPixmap::fromImage(qimgOriginal));

    // Output Eye in the Sky to screen
    // map QImage to QLabel
    cvtColor(matEyeInTheSky, matEyeInTheSky, COLOR_BGR2RGB);
    QImage qimgEyeInTheSky((uchar*)matEyeInTheSky.data, matEyeInTheSky.cols, matEyeInTheSky.rows, matEyeInTheSky.step, QImage::Format_RGB888);
    ui->sky_input->setPixmap(QPixmap::fromImage(qimgEyeInTheSky));

    // Process IK code.

     }

 }

0 个答案:

没有答案