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. Sharing QCamera object between threads

Sharing QCamera object between threads

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 780 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.
  • alexRHTA Offline
    alexRHTA Offline
    alexRHT
    wrote on last edited by
    #1

    Hello,

    I am having trouble using a webcam in two different classes each of which create their own QCamera object.

    When the second one does QCamera *cam = new QCamera, the debugger shows the message "failed to start". I suppose this is because the resource (webcam) is locked by the first class (in its thread) and it cannot be "taken" by a second.

    As the objects are not used simultaneously, I am thinking of destroying the object one class creates to create another in the other class and "play this game" over and over again. But I suppose this is inneficient and there is a simpler way to share my webcam between two classes.

    Any ideas without having to provide the specific code? A simple example would be much appreciated.

    Thanks in advance!

    1 Reply Last reply
    1
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      create an independent objects that takes care of interacting with the QCamera then from either of the two treads emit a signal like askForCamera(int) where the argument is an id of the caller, the camera will do it's job and emit another signal for example cameraData(int,QImage) with the result, the first argument is used to determine who the image belongs to

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      alexRHTA 1 Reply Last reply
      1
      • VRoninV VRonin

        create an independent objects that takes care of interacting with the QCamera then from either of the two treads emit a signal like askForCamera(int) where the argument is an id of the caller, the camera will do it's job and emit another signal for example cameraData(int,QImage) with the result, the first argument is used to determine who the image belongs to

        alexRHTA Offline
        alexRHTA Offline
        alexRHT
        wrote on last edited by
        #3

        @VRonin Thanks for your solution! I am now using a dirtier one. I will eventually apply yours as it is cleaner.

        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