Important: Please read the Qt Code of Conduct -

QGraphicsView ImageCapture and Video Record Start Hangs Camera Stream

  • Hi,

    I am having iMX6 development kit with CMOS-MIPI-OV5640. The kit is having Debian Stretch 9.5.

    At present, I am trying to Capture Image and Record Video using QT (QCamera with QGraphicsView). I have developed sample code for that and it is working fine with the laptop(ubuntu 16.04) and it's webcam.
    But on IMX6 development kit, It hangs the live stream and crashes with below cases.

    1. While ImageCapture, It hangs after capturing Image
    2. While Record Start, It hangs with mediarecorder->record().

    Please find code related to camera:

    QGraphicsVideoItem *recVideoItem = new QGraphicsVideoItem();
    QGraphicsScene *scene = new QGraphicsScene(this);

    QCamera *camera = new QCamera(this);

    //Image Capture Initialize
    QCameraImageCapture *imageCapture = new QCameraImageCapture(camera);

    //MediaRecorder Initialize
    QMediaRecorder* mediaRecorder = new QMediaRecorder(camera);
    connect(mediaRecorder, SIGNAL(durationChanged(qint64)),this, SLOT(updateRecordTime()));

    //Start Camera

    //Capture Image
    void MainWindow::on_captureImage_clicked() {
    static int count = 0;
    QImage image(scene->sceneRect().size().toSize(), QImage::Format_ARGB32); // Create the image with the exact size of the shrunk scene
    image.fill(Qt::transparent); // Start all pixels transparent

    QPainter painter(&image);
    scene->render(&painter);"SNAP_"+ QString::number(count) + ".png");
    count++;							 	      //Stops working after this Line


    //Start Record
    void MainWindow::StartRecord()
    static int iVideoCount = 0;
    mediaRecorder->setOutputLocation(QUrl::fromLocalFile(DATA_STORE_LOCATION"CLIP_"+ QString::number(iVideoCount)));

    Looking forward to hearing from you.

    Thank You,
    Nikita Panchal

  • Lifetime Qt Champion


    Where exactly do you write these files on your iMX6 device ?

  • Thanks for your response.

    Yes, I am running an application on the imx6 platform using the root user.
    Location of application is : /home/user/CameraApp
    Location of capturing files is : /root/Pictures

    I printed the error and I found that on clicking "capture Image (on_captureImage_clicked())", It gives "CameraBin error: Internal data stream error."


  • Lifetime Qt Champion

    Can you run your capture successfully using GStreamer on your board ?

  • Hi,

    First of all thanks for looking in the issue.

    Yes, I can run capture successfully using below GStreamer command:
    gst-launch-1.0 imxv4l2videosrc num-buffers=1 ! jpegenc ! filesink location=test.jpg

    While looking in issue, I found that capture and record are working fine with QVideoWidget and QCameraViewfinder but hangs with QGraphicsView.


  • Lifetime Qt Champion

    Out of curiosity, any particular reason to use QGraphicsView ?

Log in to reply