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

时光怂恿深爱的人放手 提交于 2019-11-30 16:58:50

问题


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

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

回答1:


Check if you have all dependencies installed. They are:

qtmultimedia5-dev

_

libqt5multimedia5-plugins

Ex:

sudo apt-get install libqt5multimedia5-plugins



回答2:


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();
}


来源:https://stackoverflow.com/questions/37650773/defaultserviceproviderrequestservice-no-service-found-for-org-qt-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!