0

I'm trying to connect to a UVC compatible camera on OS X. Using the hello world example from libuvc, my camera outputs this:

DEVICE CONFIGURATION (2560:c114/39254404) ---
Status: idle
VideoControl:
    bcdUVC: 0x0100
VideoStreaming(1):
    bEndpointAddress: 131
    Formats:
    UncompressedFormat(1)
          bits per pixel: 16
          GUID: 5931362000001000800000aa00389b71
          default frame: 1
          aspect ration: 0x0
          interlace flags: 00
          copy protect: 00
            FrameDescriptor(1)
              capabilities: 00
              size: 752x480
              bit rate: 346521600-346521600
              max frame size: 721920
              default interval: 1/60
              interval[0]: 1/60
              interval[1]: 1/30
            FrameDescriptor(2)
              capabilities: 00
              size: 640x480
              bit rate: 294912000-294912000
              max frame size: 614400
              default interval: 1/60
              interval[0]: 1/60
              interval[1]: 1/30
            FrameDescriptor(3)
              capabilities: 00
              size: 320x240
              bit rate: 73728000-73728000
              max frame size: 153600
              default interval: 1/60
              interval[0]: 1/60
    UncompressedFormat(2)
          bits per pixel: 24
          GUID: 7deb36e44f52ce119f530020af0ba770
          default frame: 1
          aspect ration: 0x0
          interlace flags: 00
          copy protect: 00
            FrameDescriptor(1)
              capabilities: 00
              size: 752x480
              bit rate: 519782400-519782400
              max frame size: 1082880
              default interval: 1/60
              interval[0]: 1/60
              interval[1]: 1/30
            FrameDescriptor(2)
              capabilities: 00
              size: 640x480
              bit rate: 442368000-442368000
              max frame size: 921600
              default interval: 1/60
              interval[0]: 1/60
              interval[1]: 1/30
            FrameDescriptor(3)
              capabilities: 00
              size: 320x240
              bit rate: 110592000-110592000
              max frame size: 230400
              default interval: 1/60
              interval[0]: 1/60
END DEVICE CONFIGURATION

However none of the frame formats seem to work, i.e.

res = uvc_get_stream_ctrl_format_size(
                  devh, &ctrl,
                  UVC_FRAME_FORMAT_YUYV,
                  752, 480, 60 /* width, height, fps */
              );

Whatever frame format I try (I tried looping over the enum) I get something like this:

UVC initialized
Device found
Device opened
get_mode: Invalid mode (-51)
Device closed
UVC exited

The camera works fine in Windows and in Linux under ROS. What frame format should I use? Given the configuration, I hoped UVC_FRAME_FORMAT_RGB would work, but no dice. The code for libuvc seems to compare the UVC frame format to what the device provided, but I don't understand how it determines what's a valid format.

Josh
  • 2,658
  • 31
  • 36
  • Maybe try using `uncompressed` mode and/or lower resolution. – l'L'l Apr 11 '17 at 01:33
  • I've tried 640x480, though I know the cameras are fine at 752/480/60. I've also tried all the available frame formats via a loop (there are only 9 or so), one of which will be uncompressed. Even passing `0` didn't work, which should give a default, so maybe it's an initial resolution thing. https://github.com/ktossell/libuvc/blob/master/include/libuvc/libuvc.h#L59 – Josh Apr 11 '17 at 09:30
  • I think maybe you need a `,` after `UVC_FRAME_FORMAT_YUYV` – l'L'l Apr 11 '17 at 12:05
  • Typo from copying - the code compiles correctly. (fixed) – Josh Apr 11 '17 at 12:43

1 Answers1

2

You have to use

const uvc_format_desc_t *uvc_get_format_descs(uvc_device_handle_t* )

The returned pointer to uvc_format_desc_t will contain the first available format that is valid for the given camera. You can then iterate through all possible formats with the next pointer in uvc_format_desc_t.

frame_descs in uvc_format_desc_t contains width height etc.

bDescriptorSubtype in uvc_format_desc_t contains the format e.g. UVC_VS_FORMAT_UNCOMPRESSED

  • This is getting there, the first description is `UVC_VS_FORMAT_UNCOMPRESSED` and the rest of the parameters are as I expected. Still get the same -51 error. I'm also getting an error `unsupported descriptor subtype: 3` when I call `uvc_get_format_descs`. Seems like other people have had problems getting libuvc to work with this camera manufacturer. I'll have another hack first, but otherwise I'm willing to accept this as the answer because it does solve the "what format should I be using" question. – Josh Jun 09 '17 at 01:15
  • Is there a forum for this anywhere? I was into a github site (https://github.com/libuvc/libuvc) which seemed a bit flaky then I realized there could be many forks and I'm looking at the wrong one. I get some images but have no control over the resolution and there are frequent segfaults. I'm trying to do astronomy with a Svbony camera at 3264x2448 pixels. – Alan Corey Feb 01 '23 at 02:09