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);
    scene->addItem(recVideoItem);
    ui->graphicsView->setScene(scene);

    QCamera *camera = new QCamera(this);
    camera->setViewfinder(recVideoItem);
    camera->setCaptureMode(QCamera::CaptureVideo);

    //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
    ui->graphicsView->show();
    camera->start();

    //Capture Image
    void MainWindow::on_captureImage_clicked() {
    static int count = 0;
    scene->clearSelection();
    scene->setSceneRect(scene->itemsBoundingRect());
    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);
    image.save(DATA_STORE_LOCATION"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)));
    mediaRecorder->record();
    iVideoCount++;
    }

    Looking forward to hearing from you.

    Thank You,
    Nikita Panchal


  • Lifetime Qt Champion

    Hi,

    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

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

    Thanks,
    Nikita


  • 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.

    Thanks,
    Nikita


  • Lifetime Qt Champion

    Out of curiosity, any particular reason to use QGraphicsView ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.