QCamera Windows "failed to start"

5

I made a QT application 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 the Mac it worked perfectly, but in Windows only instance the first, the second generates error. Here is 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();
    
asked by anonymous 30.06.2015 / 20:57

1 answer

0

I solved it as follows: manually implemented camera rendering, rendered a QPixMap, and displayed in 2 QLabel, because on Windows when a camera is accessed, it leaves your instance as busy.

    
28.07.2015 / 18:40