Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).

#1 10-12-2019 15:04:11

joffrey575
Membre
Distrib. : Debian Jessie et stretch
Inscription : 19-12-2016

Création d'une vidéo surveillance maison

Bonjour à tous,

Après avoir cherché comment capturer les données de ma webcam avec la lib uvc, je me heurte au problème suivant "attempt to claim already-claimed interface 1".

La méthode de ma classe dans QtCreator :

      /* Initialize a UVC service context. Libuvc will set up its own libusb
       * context. Replace NULL with a libusb_context pointer to run libuvc
       * from an existing libusb context. */

      res = uvc_init(&ctx, NULL);
      if (res < 0) {
        uvc_perror(res, "uvc_init");
        return res;
      }
      puts("UVC initialized");
      /* Locates the first attached UVC device, stores in dev */
      res = uvc_find_device(
          ctx, &dev,
          3141, 25409, NULL); /* filter devices: vendor_id, product_id, "serial_num" */
          //33006, 48, NULL);
          //3141, 25409, NULL); /* filter devices: vendor_id, product_id, "serial_num" */
          //3141, 25409, "da1b7b94a31315e0");

      if (res < 0) {
        uvc_perror(res, "uvc_find_device"); /* no devices found */
      } else {
        puts("Device found");

        /* Try to open the device: requires exclusive access */
        //Special access : sudo sh -c "echo 'SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0c45\", ATTRS{idProduct}==\"6341\", SYMLINK+=\"pt1\", GROUP=\"usb\", MODE=\"666\"' > /etc/udev/rules.d/99-pt1.rules"
        res = uvc_open(dev, &devh);

        if (res < 0) {
          uvc_perror(res, "uvc_open"); /* unable to open device */
        } else {
          puts("Device opened");
          /* Print out a message containing all the information that libuvc
           * knows about the device */

          uvc_print_diag(devh, stderr);

          /* Try to negotiate a 640x480 30 fps YUYV stream profile */
          res = uvc_get_stream_ctrl_format_size(
              devh, &ctrl, /* result stored in ctrl */
              UVC_FRAME_FORMAT_YUYV, /* YUV 422, aka YUV 4:2:2. try _COMPRESSED */
              640, 480, 30 /* width, height, fps */
          );

          /* Print out the result */
          uvc_print_stream_ctrl(&ctrl, stderr);
          if (res < 0) {
            uvc_perror(res, "get_mode"); /* device doesn't provide a matching stream */
          } else {
            /* Start the video stream. The library will call user function cb:
             *   cb(frame, (void*) 12345)
             */


            res = uvc_start_streaming(devh, &ctrl, cb, user_ptr, 0);
            if (res < 0) {
              uvc_perror(res, "start_streaming"); /* unable to start stream */
            } else {
              puts("Streaming...");
              uvc_set_ae_mode(devh, 1); /* e.g., turn on auto exposure */
              QThread::msleep(10000); /* stream for 10 seconds */
              /* End the stream. Blocks until last callback is serviced */
              uvc_stop_streaming(devh);
              puts("Done streaming.");
            }
          }
          /* Release our handle on the device */
          uvc_close(devh);
          puts("Device closed");
        }
        /* Release the device descriptor */
        uvc_unref_device(dev);
      }
      /* Close the UVC context. This closes and cleans up any existing device handles,
       * and it closes the libusb context if one was not provided. */

      uvc_exit(ctx);
      puts("UVC exited");
      return 0;



Le résultat :



14:47:00: Starting /home/jo/Qt_project/serveur_surveillance/build-serveur_surveillance-Desktop-Debug/serveur_surveillance...
TEST
4 Devices in list.
Number of possible configurations: 1  Device Class: 239  VendorID: 3141  ProductID: 25409
Interfaces: 4 ||| Number of alternate settings: 1 | Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 131 | Number of alternate settings: 7 | Interface Number: 1 | Number of endpoints: 0 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Interface Number: 1 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 | Number of alternate settings: 1 | Interface Number: 2 | Number of endpoints: 0 | Number of alternate settings: 2 | Interface Number: 3 | Number of endpoints: 0 | Interface Number: 3 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 132 |


Number of possible configurations: 1  Device Class: 9  VendorID: 7531  ProductID: 2
Interfaces: 1 ||| Number of alternate settings: 1 | Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 |


Number of possible configurations: 1  Device Class: 0  VendorID: 33006  ProductID: 33
Interfaces: 1 ||| Number of alternate settings: 1 | Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 |


Number of possible configurations: 1  Device Class: 9  VendorID: 7531  ProductID: 1
Interfaces: 1 ||| Number of alternate settings: 1 | Interface Number: 0 | Number of endpoints: 1 | Descriptor Type: 5 | EP Address: 129 |


unsupported descriptor subtype VS_STILL_IMAGE_FRAME
unsupported descriptor subtype VS_STILL_IMAGE_FRAME
unsupported descriptor subtype VS_COLORFORMAT
DEVICE CONFIGURATION (0c45:6341/[none]) ---
Status: idle
VideoControl:
  bcdUVC: 0x0100
VideoStreaming(1):
  bEndpointAddress: 129
  Formats:
  UncompressedFormat(1)
      bits per pixel: 16
      GUID: 5955593200001000800000aa00389b71 (YUY2)
      default frame: 1
      aspect ratio: 0x0
      interlace flags: 00
      copy protect: 00
      FrameDescriptor(1)
        capabilities: 00
        size: 640x480
        bit rate: 24576000-147456000
        max frame size: 614400
        default interval: 1/30
        interval[0]: 1/30
        interval[1]: 1/25
        interval[2]: 1/20
        interval[3]: 1/15
        interval[4]: 1/10
        interval[5]: 1/5
                           .......................
      FrameDescriptor(18)
        capabilities: 00
        size: 1280x720
        bit rate: 73728000-147456000
        max frame size: 1843200
        default interval: 1/10
        interval[0]: 1/10
        interval[1]: 1/5
  MJPEGFormat(2)
      bits per pixel: 0
      GUID: 4d4a5047000000000000000000000000 (MJPG)
      default frame: 1
      aspect ratio: 0x0
      interlace flags: 00
      copy protect: 00
      FrameDescriptor(1)
        capabilities: 00
        size: 640x480
        bit rate: 24599560-147597360
        max frame size: 614989
        default interval: 1/30
        interval[0]: 1/30
        interval[1]: 1/25
        interval[2]: 1/20
        interval[3]: 1/15
        interval[4]: 1/10
        interval[5]: 1/5
                          ......................
      FrameDescriptor(18)
        capabilities: 00
        size: 1280x720
        bit rate: 73751560-442509360
        max frame size: 1843789
        default interval: 1/30
        interval[0]: 1/30
        interval[1]: 1/25
        interval[2]: 1/20
        interval[3]: 1/15
        interval[4]: 1/10
        interval[5]: 1/5
END DEVICE CONFIGURATION
bmHint: 0001
bFormatIndex: 1
bFrameIndex: 1
dwFrameInterval: 333333
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 0
wCompWindowSize: 0
wDelay: 13646
dwMaxVideoFrameSize: 614400
dwMaxPayloadTransferSize: 3072
bInterfaceNumber: 1
attempt to claim already-claimed interface 1
14:47:01: Le programme s'est terminé subitement.
14:47:01: The process was ended forcefully.
14:47:01: /home/jo/Qt_project/serveur_surveillance/build-serveur_surveillance-Desktop-Debug/serveur_surveillance crashed.



Merci pour votre retour d'expérience.

Hors ligne

#2 10-12-2019 15:26:48

lagrenouille
Adhérent(e)
Lieu : Toulouse, con !
Distrib. : debian buster - openbsd
Noyau : d'olive
(G)UI : env i3-openbox_bépo
Inscription : 28-03-2012
Site Web

Re : Création d'une vidéo surveillance maison

moi j'ai mis un crapaud à l'entrée de ma maison, quand il crôasse, je sais qu'il y a quelqu'un
et hop, je lui demande le signalement   yikes lol

Veuillez laisser l’État dans la malpropreté ou vous avez trouvé en y entrant.

Hors ligne

Pied de page des forums