0

我正在尝试连接到 OS X 上的 UVC 兼容相机。使用 hello world 示例libuvc,我的相机输出以下内容:

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

然而,没有一种帧格式似乎工作,即

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

无论我尝试什么帧格式(我尝试遍历枚举),我都会得到这样的结果:

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

该摄像头在 Windows 和 ROS 下的 Linux 中运行良好。我应该使用什么帧格式?鉴于配置,我希望UVC_FRAME_FORMAT_RGB可以工作,但没有骰子。libuvc 的代码似乎将 UVC 帧格式与设备提供的格式进行了比较,但我不明白它如何确定什么是有效格式。

4

1 回答 1

1

你必须使用

const uvc_format_desc_t *uvc_get_format_descs(uvc_device_handle_t* )

返回的指针uvc_format_desc_t将包含对给定相机有效的第一个可用格式。next然后,您可以使用 中的指针遍历所有可能的格式uvc_format_desc_t

frame_descsinuvc_format_desc_t包含宽度高度等。

bDescriptorSubtypeinuvc_format_desc_t包含格式,例如 UVC_VS_FORMAT_UNCOMPRESSED

于 2017-06-05T15:53:35.690 回答