Qt camera example not working

I am trying to run a QCamera example on Ubuntu, Qt 5.6. The message "Camera service is missing."

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.camera" 
+7
ubuntu
source share
2 answers

Check if all dependencies are installed. It:

qtmultimedia5-dev

_

libqt5multimedia5 plugins

Example:

 sudo apt-get install libqt5multimedia5-plugins 
+1
source share

By checking the code example, it seems that the example is trying to create a camera object with a default camera. The setCamera method is obviously being called with incorrect camera information.

  setCamera(QCameraInfo::defaultCamera()); 

You can make sure that by changing it to

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

Obviously, the camera will be found from /dev/video0 . You can check if it exists. If your camera looks like video1 or video2, you can rename it to video0 and try again.

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

 foreach (const QCameraInfo &cameraInfo, QCameraInfo::availableCameras()) { { qDebug() << cameraInfo.deviceName(); } 
0
source share

All Articles