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