Qcamera Windows "failed to start"

Asked

Viewed 180 times

5

I made an application with QT where I make the instance of a Camera with QT and display it in the window. So far so good, the problem is that when I want to display it in another window (Qdialog) I get the error "failed to start". I wanted both windows to display the same camera. On Mac it worked perfectly, but on Windows only instance the first, the second generates error. Follow the code that generates the error:

void MainWindow::setCameras(const QCameraInfo camera_info_1, const QCameraInfo camera_info_2){
    if(!camera_info_1.isNull()){
        camera_1 = new QCamera(camera_info_1);
        this->camera_info_1 = camera_info_1;
    }

    if(!camera_info_2.isNull()){
        camera_2 = new QCamera(camera_info_2);
        this->camera_info_2 = camera_info_2;
    }
}

/** inicia as cameras pré configuradas **/
void MainWindow::startCameras() {
    if(camera_1 != NULL){
        camera_1->setViewfinder(ui->cameraVizualizar);
        camera_1->start();
    }
    if(camera_2 != NULL){
        camera_2->setViewfinder(ui->cameraVizualizar_2);
        camera_2->start();
    }
}

Who calls these methods, are these lines in the main file:

QCameraInfo cameraTMP_01 = QCameraInfo::defaultCamera();
QCameraInfo cameraTMP_02 = QCameraInfo::defaultCamera();

MainWindow w;
w.setCameras(cameraTMP_01, cameraTMP_02);
w.startCameras();
w.show();
  • I decided as follows: I manually implemented the rendering of the camera, generated a Qpixmap and displayed in 2 Qlabel, because in Windows when accessing a camera, it leaves its instance as busy.

  • I am closing as out of scope by what has been described to be expected behavior. You can only open one instance at a time.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.