Skip to content
  • 0 Votes
    2 Posts
    506 Views
    A

    I added the following two lines of code and it worked:

    QHBoxLayout *camera_layout = new QHBoxLayout(this); mCamera = new QCamera(); mCameraViewfinder = new QCameraViewfinder(); camera_layout->addWidget(mCameraViewfinder); mCamera->setViewfinder(mCameraViewfinder); mCamera->start();

    And it worked

  • QCamera Problems

    Unsolved General and Desktop
    3
    0 Votes
    3 Posts
    1k Views
    B

    This is a bug in 5.9.0. The newer version 5.9.2 does not have the crash problem

  • 1 Votes
    2 Posts
    2k Views
    pauleddP

    I think I found a solution. I roughly quadrupled the QCameraViewfinder size and repositioned it to the middle.
    Its all done with "cameraVf->setGeometry(x,y,x,y);". And I parented the viewfinder to a new QFrame
    to have a frame and to have the viewfinder not overlaying the start button.

    alt text

    mainwindow.cpp

    ... QFrame *frameVideo = new QFrame(frame4); // extra frame where the video is in frameVideo->setGeometry(5,35,375,380); camera = new QCamera("/dev/video0"); cameraVf = new QCameraViewfinder(frameVideo); camera->setViewfinder(cameraVf); cameraVf->setGeometry(0,0,375,380); QCameraViewfinderSettings vfsettings; vfsettings.setPixelFormat(QVideoFrame::Format_YUV420P); vfsettings.setResolution(640,480); camera->setViewfinderSettings(vfsettings); cameraVf->show(); ... void MainWindow::onZoomClicked(){ if(cameraVf->width() != 1600) { cameraVf->setGeometry(-590,-490,1600,1440); // zoom in } else { cameraVf->setGeometry(0,0,375,380); // zoom out } }