Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QT Camera example



  • Hi,
    I am trying to use the qtcamera example application. It worked perfectly while i was using my USB camera. But i have another h/w connected camera which i want to use.
    When i looked at the devices only usb camera was detected and hw camera was not.

    What changes do you think i should make to make the h/w camera work?

    As of now i am using gstreamer commands,
    sudo gst-launch-1.0 v4l2src device=/dev/video1 ! 'video/x-raw,format=UYVY,width=1920,height=1080' ! glimagesink
    Any help will be appreciated :)
    Thanks in advance


  • Lifetime Qt Champion

    Hi,

    What type of camera is that ?


  • Lifetime Qt Champion

    I just remembered that if you use a more recent version of Qt, you can use custom gstreamer pipelines. See the corresponding Qt documentation.



  • @SGaist Hey thanks for answering.
    But i think I might need little more help here.

    So when i was going through the code i found the part which is searching for the camera device,
    ui->setupUi(this);

    //Camera devices:
    QByteArray cameraDevice;
    
    QActionGroup *videoDevicesGroup = new QActionGroup(this);
    videoDevicesGroup->setExclusive(true);
    foreach(const QByteArray &deviceName, QCamera::availableDevices()) {
        QString description = camera->deviceDescription(deviceName);
        QAction *videoDeviceAction = new QAction(description, videoDevicesGroup);
        videoDeviceAction->setCheckable(true);
        videoDeviceAction->setData(QVariant(deviceName));
        if (cameraDevice.isEmpty()) {
            cameraDevice = deviceName;
            videoDeviceAction->setChecked(true);
        }
        ui->menuDevices->addAction(videoDeviceAction);
    }
    
    connect(videoDevicesGroup, SIGNAL(triggered(QAction*)), SLOT(updateCameraDevice(QAction*)));
    connect(ui->captureWidget, SIGNAL(currentChanged(int)), SLOT(updateCaptureMode()));
    

    #ifdef HAVE_CAMERA_BUTTONS
    ui->lockButton->hide();
    #endif

    setCamera(cameraDevice);
    

    }

    So you are saying i should replace the above code with this command " sudo gst-launch-1.0 v4l2src device=/dev/video1 ! 'video/x-raw,format=UYVY,width=1920,height=1080' ! glimagesink " ??
    Can you help me out to do this?


  • Lifetime Qt Champion



  • @SGaist :
    So URL should be something like ,
    QUrl("gst-pipeline:v4l2src device=/dev/video1 ! 'video/x-raw,format=UYVY,width=1920,height=1080' ! glimagesink "); ?


  • Lifetime Qt Champion

    As shown in the documentation I linked, you need a video sink named qtvideosink.


Log in to reply