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. Detect hardware button events on a USB camera
Forum Updated to NodeBB v4.3 + New Features

Detect hardware button events on a USB camera

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.9k 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.
  • U Offline
    U Offline
    uranusjr
    wrote on last edited by
    #1

    Hi,

    I'm trying to develop a desktop app with QML on Qt 5.2 that controls a USB-attached camera. I can already control the camera with software buttons, but want to have access to the camera's hardware button (it has one for shutter) too.

    Since there are no hardware-related functionalities in Qt's camera API (either QCamera and the QML Camera element), my first thought was to read the button myself. I put together some simple C++ that reads the device on LibUSB, and it worked well enough—on its own. I found that when I tried to integrate the two parts together, Qt's camera API would spit out "Failed to create video device input" and stop working altogether.

    I'm not very familiar with LibUSB, to be honest. Is this caused by some ownership problem between Qt and my LibUSB code? If so, how do I resolve this? Or is there a completely different way of doing this without digging into raw USB communication on my own?

    Thanks in advance.

    F 1 Reply Last reply
    0
    • M Offline
      M Offline
      mkandefer
      wrote on last edited by
      #2

      I'm by no means an expert on this, but have been trying essentially the same thing. Only one process can access the USB device at one time, from my understanding, and thus you need to incorporate a mutex or some polling function that releases control of the video stream to check the button status. This does mean that you're going to be writing your own custom driver for the camera if it didn't come with one. If anyone with better understanding of QCamera and USB controls can chime in with assistance it'd be appreciated.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Felix.Yin
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • U uranusjr

          Hi,

          I'm trying to develop a desktop app with QML on Qt 5.2 that controls a USB-attached camera. I can already control the camera with software buttons, but want to have access to the camera's hardware button (it has one for shutter) too.

          Since there are no hardware-related functionalities in Qt's camera API (either QCamera and the QML Camera element), my first thought was to read the button myself. I put together some simple C++ that reads the device on LibUSB, and it worked well enough—on its own. I found that when I tried to integrate the two parts together, Qt's camera API would spit out "Failed to create video device input" and stop working altogether.

          I'm not very familiar with LibUSB, to be honest. Is this caused by some ownership problem between Qt and my LibUSB code? If so, how do I resolve this? Or is there a completely different way of doing this without digging into raw USB communication on my own?

          Thanks in advance.

          F Offline
          F Offline
          Felix.Yin
          wrote on last edited by
          #4

          @uranusjr Hi, I have met the same problem. I wonder if you have solved it!

          1 Reply Last reply
          0
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi @Felix.Yin

            Only one process can access the USB device at one time

            I think the problem is, once you opened the connection to the camera, a second access is not possible.

            The solution would be, IMHO,, to modify the Qt camera code to add the new functions. You can do this for your own Qt copy (mind the GPL: you have to release the sources or use a commercial license!) or even propose a change in the official Qt API.

            (This is just my bird's view of understanding, I have not looked up the Qt camera code).

            Regards

            Qt has to stay free or it will die.

            F 1 Reply Last reply
            0
            • aha_1980A aha_1980

              Hi @Felix.Yin

              Only one process can access the USB device at one time

              I think the problem is, once you opened the connection to the camera, a second access is not possible.

              The solution would be, IMHO,, to modify the Qt camera code to add the new functions. You can do this for your own Qt copy (mind the GPL: you have to release the sources or use a commercial license!) or even propose a change in the official Qt API.

              (This is just my bird's view of understanding, I have not looked up the Qt camera code).

              Regards

              F Offline
              F Offline
              Felix.Yin
              wrote on last edited by
              #6

              @aha_1980 Thank you for your advice. It seems libusb is dead.
              I have a search for a solution on linux https://stackoverflow.com/questions/29355100/uvc-camera-still-pin-capture-in-linux-c
              But there is no libevdev on osx.

              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