Important: Please read the Qt Code of Conduct -

QAbstractVideoSurface camera frames brightness

  • Hi everyone,

    I implemented a QAbstractVideoSurface, and a widget to be painted based on this example.
    Everything works fine, but the camera preview I get is very dark compared to the result I get when I use a QCameraViewfinder or QVideoWidget.
    Here's the code I am using to create the QCamera:

    m_camera = new QCamera(this);
    connect(m_camera, &QCamera::statusChanged, this, &MainWindow::cameraStatusChanged);
    m_camera->setViewfinder(ui->videoWidget->videoSurface()); // videoSurface is a QAbstractVideoSurface

    And here's the slot 'cameraStatusChanged':

    void MainWindow::cameraStatusChanged(QCamera::Status status)
        if(status == QCamera::LoadedStatus)
            m_cameraLoaded = true;
            QCameraImageProcessing *imgProcessing = m_camera->imageProcessing();
                qDebug() << "image processing available";
        else if(status == QCamera::UnloadedStatus)
            m_cameraLoaded = false;

    Unfortunately, the brightness and the other filters (like the saturation) don't work and the preview video is still dark.

    How can I change the brightness of my video frames?
    Do I need to implement my own QVideoWidget and a QPainterVideoSurface (which is undocumented) ?
    Thank you in advance.

    EDIT: Is there a way to adjust the brightness automatically, as the QVideoWidget does?

  • For those who implemented a QAbstractVideoSurface: didn't anyone have that problem?

Log in to reply