defaultServiceProvider::requestService(): no service found for - “org.qt-project.qt.camera”

后端 未结 2 2067
清酒与你
清酒与你 2021-01-05 08:33

I\'m trying to execute QCamera example on Ubuntu, Qt 5.6. \"The camera service is missing\" message observed.

defaultServiceProvider::requestService(): no s         


        
相关标签:
2条回答
  • 2021-01-05 08:49

    Check if you have all dependencies installed. They are:

    qtmultimedia5-dev

    _

    libqt5multimedia5-plugins

    Ex:

    sudo apt-get install libqt5multimedia5-plugins
    
    0 讨论(0)
  • 2021-01-05 08:56

    Checking the example code it seems the example tries to construct the camera object with default camera. Method setCamera is obviously called with camera info which is not valid.

        setCamera(QCameraInfo::defaultCamera());
    

    You can verify that by changing it to

    QCameraInfo info = QCameraInfo::defaultCamera();
    if (!info.isNull())
    {
        setCamera(info);
    }
    else
    {
        qError() << "Default camera not found!";
    }
    

    It obviously expects the camera to be found from /dev/video0. You could check if it exists. If your camera is something like video1 or video2, you could rename it to video0 and try again.

    You can also add a debug message to the for-loop in Camera class constructor to see device names of available cameras (and modify the code to select other than default camera).

    foreach (const QCameraInfo &cameraInfo, QCameraInfo::availableCameras()) {
    {
        qDebug() << cameraInfo.deviceName();
    }
    
    0 讨论(0)
提交回复
热议问题