<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Camera inconsistent startup in QtMultimedia]]></title><description><![CDATA[<p dir="auto">So this is a little weird and I'm sort of a noob so please bear with me. I need to set up a camera for capturing still images in my app. I've been using this code, just throwing it in my MainWindow now for testing purposes: <a href="https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimediawidgets/camera?h=5.15" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimediawidgets/camera?h=5.15</a></p>
<p dir="auto">The problem is that when I first start the app with my usb camera, the light will flash for a bit then turn solid like it should be on, but there is no image displayed on the widget. However, if I stop and restart the app quickly then the light on the camera behave the same way, but the image is displayed correctly.  It feels like the camera has to "warm up" and if it's allowed to get "cold" it won't work anymore. I don't know how else to describe it and I have no errors to go on. The state changes of the camera are identical either way. Can anyone help with this?</p>
<p dir="auto">I'm on ubuntu 20, qt 5.12.8.</p>
<pre><code>    QActionGroup *videoDevicesGroup = new QActionGroup(this);
    videoDevicesGroup-&gt;setExclusive(true);
    const QList&lt;QCameraInfo&gt; availableCameras = QCameraInfo::availableCameras();
    qDebug() &lt;&lt; availableCameras;
    for (const QCameraInfo &amp;cameraInfo : availableCameras) {
        QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup);
        videoDeviceAction-&gt;setCheckable(true);
        qDebug() &lt;&lt; cameraInfo;

        videoDeviceAction-&gt;setData(QVariant("/dev/video0"));
        if (cameraInfo == QCameraInfo::defaultCamera())
            videoDeviceAction-&gt;setChecked(true);
            qDebug() &lt;&lt; videoDeviceAction;

        //ui-&gt;menuDevices-&gt;addAction(videoDeviceAction);
    }

    //connect(videoDevicesGroup, &amp;QActionGroup::triggered, this, &amp;Camera::updateCameraDevice);
    //connect(ui-&gt;captureWidget, &amp;QTabWidget::currentChanged, this, &amp;Camera::updateCaptureMode);

    setCamera(QCameraInfo::defaultCamera());
}

void MainWindow::setCamera(const QCameraInfo &amp;cameraInfo)
{
    m_camera.reset(new QCamera(cameraInfo));

    connect(m_camera.data(), &amp;QCamera::stateChanged, this, &amp;MainWindow::updateCameraState);
    connect(m_camera.data(), QOverload&lt;QCamera::Error&gt;::of(&amp;QCamera::error), this, &amp;MainWindow::displayCameraError);

//    m_mediaRecorder.reset(new QMediaRecorder(m_camera.data()));
//    connect(m_mediaRecorder.data(), &amp;QMediaRecorder::stateChanged, this, &amp;MainWindow::updateRecorderState);

//    m_imageCapture.reset(new QCameraImageCapture(m_camera.data()));

//    connect(m_mediaRecorder.data(), &amp;QMediaRecorder::durationChanged, this, &amp;MainWindow::updateRecordTime);
//    connect(m_mediaRecorder.data(), QOverload&lt;QMediaRecorder::Error&gt;::of(&amp;QMediaRecorder::error),
//            this, &amp;MainWindow::displayRecorderError);

//    m_mediaRecorder-&gt;setMetaData(QMediaMetaData::Title, QVariant(QLatin1String("Test Title")));

//    connect(ui-&gt;exposureCompensation, &amp;QAbstractSlider::valueChanged, this, &amp;MainWindow::setExposureCompensation);
    updateCameraState(m_camera-&gt;state());
//    updateLockStatus(m_camera-&gt;lockStatus(), QCamera::UserRequest);
    qDebug() &lt;&lt; m_camera-&gt;lockStatus();
//    updateRecorderState(m_mediaRecorder-&gt;state());

//    connect(m_imageCapture.data(), &amp;QCameraImageCapture::readyForCaptureChanged, this, &amp;MainWindow::readyForCapture);
//    connect(m_imageCapture.data(), &amp;QCameraImageCapture::imageCaptured, this, &amp;MainWindow::processCapturedImage);
//    connect(m_imageCapture.data(), &amp;QCameraImageCapture::imageSaved, this, &amp;MainWindow::imageSaved);
//    connect(m_imageCapture.data(), QOverload&lt;int, QCameraImageCapture::Error, const QString &amp;&gt;::of(&amp;QCameraImageCapture::error),
//            this, &amp;MainWindow::displayCaptureError);

//    connect(m_camera.data(), QOverload&lt;QCamera::LockStatus, QCamera::LockChangeReason&gt;::of(&amp;QCamera::lockStatusChanged),
//            this, &amp;MainWindow::updateLockStatus);

//    ui-&gt;captureWidget-&gt;setTabEnabled(0, (m_camera-&gt;isCaptureModeSupported(QCamera::CaptureStillImage)));
//    ui-&gt;captureWidget-&gt;setTabEnabled(1, (m_camera-&gt;isCaptureModeSupported(QCamera::CaptureVideo)));

    qDebug() &lt;&lt; m_camera-&gt;isCaptureModeSupported(QCamera::CaptureStillImage);
    qDebug() &lt;&lt; m_camera-&gt;isCaptureModeSupported(QCamera::CaptureVideo);
//    updateCaptureMode();
    m_camera-&gt;setCaptureMode(QCamera::CaptureStillImage);

    //QCameraViewfinder* viewfinder = new QCameraViewfinder();
    QVideoWidget *videoWidget = new QVideoWidget;
    m_camera-&gt;setViewfinder(videoWidget);

    //m_camera-&gt;setViewfinder(viewfinder);

    //viewfinder-&gt;show();
    videoWidget-&gt;show();
    m_camera-&gt;start();
}

</code></pre>
]]></description><link>https://forum.qt.io/topic/143964/camera-inconsistent-startup-in-qtmultimedia</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 16:30:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/143964.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Mar 2023 22:16:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Fri, 31 Mar 2023 17:43:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mzimmers">@<bdi>mzimmers</bdi></a> If it does I definitely don't have it, but I use the camera every day with google meet, obs, etc.</p>
]]></description><link>https://forum.qt.io/post/753192</link><guid isPermaLink="true">https://forum.qt.io/post/753192</guid><dc:creator><![CDATA[munderwoods]]></dc:creator><pubDate>Fri, 31 Mar 2023 17:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Fri, 31 Mar 2023 16:36:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/munderwoods">@<bdi>munderwoods</bdi></a> based on everything you've said, it sounds like a firmware bug in the original camera. Did that camera come with an app that you could try out, just to see how it works with that?</p>
]]></description><link>https://forum.qt.io/post/753188</link><guid isPermaLink="true">https://forum.qt.io/post/753188</guid><dc:creator><![CDATA[mzimmers]]></dc:creator><pubDate>Fri, 31 Mar 2023 16:36:20 GMT</pubDate></item><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Fri, 31 Mar 2023 16:14:08 GMT]]></title><description><![CDATA[<p dir="auto">I've confirmed now that this isn't an issue with a different but very similar logitech camera, so I suppose that's fine... But I'd really prefer to figure out what the problem was.</p>
]]></description><link>https://forum.qt.io/post/753183</link><guid isPermaLink="true">https://forum.qt.io/post/753183</guid><dc:creator><![CDATA[munderwoods]]></dc:creator><pubDate>Fri, 31 Mar 2023 16:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Wed, 29 Mar 2023 21:14:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/munderwoods">@<bdi>munderwoods</bdi></a> My camera works normally for all consumer applications btw.</p>
]]></description><link>https://forum.qt.io/post/752887</link><guid isPermaLink="true">https://forum.qt.io/post/752887</guid><dc:creator><![CDATA[munderwoods]]></dc:creator><pubDate>Wed, 29 Mar 2023 21:14:16 GMT</pubDate></item><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Wed, 29 Mar 2023 20:06:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Yeah, I just built multimedia/declarative-camera and it behaves identically.</p>
<p dir="auto">Here is the relevant part of dmesg:</p>
<pre><code>[ 8490.752069] usb 2-7: new high-speed USB device number 4 using xhci_hcd
[ 8491.100177] usb 2-7: New USB device found, idVendor=046d, idProduct=0828, bcdDevice= 0.11
[ 8491.100191] usb 2-7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 8491.101144] usb 2-7: Found UVC 1.00 device &lt;unnamed&gt; (046d:0828)
[ 8491.230057] input: UVC Camera (046d:0828) as /devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.0/input/input23
</code></pre>
<p dir="auto">It seems to me like it would be something about the driver, but this should be a totally standard ubuntu install, and I just plugged in my camera to a usb 2.0 port. It's a logitech C920 I think.</p>
]]></description><link>https://forum.qt.io/post/752882</link><guid isPermaLink="true">https://forum.qt.io/post/752882</guid><dc:creator><![CDATA[munderwoods]]></dc:creator><pubDate>Wed, 29 Mar 2023 20:06:46 GMT</pubDate></item><item><title><![CDATA[Reply to Camera inconsistent startup in QtMultimedia on Wed, 29 Mar 2023 19:41:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Do you have the same issue if you use the Qt Camera example ?<br />
Did you check your system logs just in case it shows something goes off with your device ?</p>
]]></description><link>https://forum.qt.io/post/752878</link><guid isPermaLink="true">https://forum.qt.io/post/752878</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 29 Mar 2023 19:41:04 GMT</pubDate></item></channel></rss>