Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get USB camera to be default
Forum Updated to NodeBB v4.3 + New Features

How to get USB camera to be default

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 222 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rtvideo
    wrote on last edited by rtvideo
    #1

    Hello, I am working on an embedded board and inside the board it has a /dev/video0 and a /dev/video1 by default. I then plug in my USB camera and it usually is /dev/video2. My current code is taking the deafult camera and (which I want to be the USB camera) thinking it is the /dev/video0.

    My code:

    int find_device(){
        QString device_name;
        std::string defaultDevice;
        const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras();
        for (const QCameraInfo &cameraInfo : availableCameras) {
            if (cameraInfo == QCameraInfo::defaultCamera()){
                   device_name = QCameraInfo::defaultCamera().deviceName();
                   defaultDevice = device_name.toStdString();
            }
        }
    

    Does anyone know how I would edit this to make the USB camera the one it defaults to or how it could find it? I dont think QCamerainfo::devicename will work for me because there are multiple USB cameras I plug in that have different names.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      That is something that you have to setup on your system. If using udev for example, write a rule that gives a meaningful name to that camera and use that in your software.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved