Camera fails when i try to start it
-
I'm trying to create a simple project that lets me use a usb camera, but i'm gettinh an error from gsstreamer and not able to start my camera.
Code:#include "mainwindow.h" #include "ui_mainwindow.h" #include <QCamera> #include <QCameraImageCapture> #include <QCameraViewfinder> #include <QVBoxLayout> #include <QMenu> #include <QAction> #include <QFileDialog> #include <QCameraInfo> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); QCameraInfo desiredCamera; for (const QCameraInfo& cameraInfo : cameras) { qDebug() << cameraInfo.description(); if (cameraInfo.description() == "GENERAL - UVC : GENERAL - UVC ") { desiredCamera = cameraInfo; //break; } } mcamera = new QCamera(desiredCamera); mCameraViewfinder =new QCameraViewfinder(this); mCameraImageCapture = new QCameraImageCapture(mcamera, this); mLayout = new QVBoxLayout; mOptionMenu = new QMenu("Options", this); mLigarAction = new QAction("Ligar", this); mDesligarAction = new QAction("Desligar", this); mCaptureAction = new QAction("Capturar", this); mOptionMenu->addActions({mLigarAction,mDesligarAction,mCaptureAction}); ui->option_pn->setMenu(mOptionMenu); mcamera->setViewfinder(mCameraViewfinder); mLayout->addWidget(mCameraViewfinder); mLayout->setMargin(0); ui->scrollArea->setLayout(mLayout); connect(mLigarAction, &QAction::triggered, [&]() { mcamera->start(); }); connect(mDesligarAction, &QAction::triggered, [&]() { mcamera->stop(); }); connect(mCaptureAction, &QAction::triggered, [&]() { auto filename = QFileDialog::getSaveFileName(this,"Capturar", "/", "Imagem (*.jpg;*.jpeg)"); if(filename.isEmpty()){ return; } mCameraImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile); QImageEncoderSettings imageEcoderSettings; imageEcoderSettings.setCodec("image/jpeg"); imageEcoderSettings.setResolution(1600,1200); mCameraImageCapture->setEncodingSettings(imageEcoderSettings); mcamera->setCaptureMode(QCamera::CaptureStillImage); mcamera->start(); mcamera->searchAndLock(); mCameraImageCapture->capture(filename); mcamera->unlock(); }); //https://forum.qt.io/topic/127481/gstreamer-critical-error-with-qcamera/3 } MainWindow::~MainWindow() { delete ui; } The error i'm getting:
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
"Integrated_Webcam_HD: Integrate"
"GENERAL - UVC : GENERAL - UVC "(teste1:63195): GStreamer-CRITICAL **: 17:19:55.647: gst_pad_get_current_caps: assertion 'GST_IS_PAD (pad)' failed
(teste1:63195): GLib-GObject-CRITICAL **: 17:19:55.647: g_object_set: assertion 'G_IS_OBJECT (object)' failed
(teste1:63195): GLib-GObject-CRITICAL **: 17:19:55.647: g_object_set: assertion 'G_IS_OBJECT (object)' failed
CameraBin error: "GStreamer error: negotiation problem."
Unable to query the parameter info: QCameraImageProcessingControl::WhiteBalancePreset : "Invalid argument"
Unable to query the parameter info: QCameraImageProcessingControl::ColorTemperature : "Invalid argument"
CameraBin error: "Internal data stream error."