Displaying multiple OpenCV VideoCapture objects in QT
-
Hey Guys, I'm capturing webcam streams from two raspberry pis and I'm trying to carry out some image processing on both streams. I have two Qlabels I'm trying to use to display the images from the pis. However, whilst one stream displays in real time, the other has a 4-5 second delay. The same result occurs if I try to display one stream on both Qlabel objects. Is this a threading issue? Can you guys please help out?
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. } }
-
Hi and welcome to devnet,
Partly it will come from your conversions and processing and the size of the image. Depending on the size of the image, it will also have an impact on the speed.
-
Hi
Did you try to show vodeo capture only from the slow one? I think it might be usefull to test if the second camera slow only when image from both cameras is shown or it's always slow.Another suggection is to try to swap devices. It may be some kind of hardware problem.
The last suggestion is to try to use QGraphicsView as soon as it might be just quicker than labels. However I don't think that the problem you described is in labels.