打印

UVC example 中如何实现一个frame size支持多个帧率

[复制链接]
5165|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zengweitotty|  楼主 | 2015-12-16 10:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 zengweitotty 于 2015-12-16 10:19 编辑


新手入门的系列文档【原创】
本贴讲解了UVC example 中如何实现一个frame size支持多个帧率,英文写的,就不翻译了。有空的时候给翻译成中文。

1. Your UVC frame descriptor need support multi frameintervals. Like following settings
/* Class specific Uncompressed VSFrame Descriptor 1 - 640x480@60fps, or 30fps*/
0x22, // Descriptor size
0x24,  // Descriptor type
0x05,  //  Subtype:uncompressed frame I/F
0x01,  // Frame DescriptorIndex = 1
0x00,  // Still image capturemethod not supported, not fixed frame rate
0x80,0x02, // Width in pixel: 640 =0x280
0xE0,0x01, //Height in pixel 480 =0x1E0
0x00,0x00,0x94,0x11, // Min bit ratebits/s. 640 pixels x 480 pixels x 2 bpp x 8 bits x 60 fps = 294912000 bits/s =0x11940000
0x00,0x00,0xCA,0x08, // Max bit ratebits/s. 640 pixels x 480 pixels x 2 bpp x 8 bits x 30 fps = 147456000 bits/s =0x8CA0000
0x00,0x60,0x09,0x00, // Maximumvideo or still frame size in bytes(Deprecated) 640 pixels x 480 pixels x 2 bpp= 614400 bytes = 0x96000
0x0A,0x8B,0x02,0x00, //0x28B0A =166816 (unit 100 ns) = 1 / (166816 * 100 ns) = 59.94fps
0x02,  //Frame interval(FrameRate) types: Only Two frame interval supported
0x0A,0x8B,0x02,0x00, //0x28B0A =166816 (unit 100 ns) = 1 / (166816 * 100 ns) = 59.94fps
0x15,0x16,0x05,0x00  //0x51615= 333333 (unit 100 ns) = 1 / (333333 * 100 ns) = 29.97fps
2.  Probe commit stage whenchange your frame rate.
Probe Stage:
               GET_CUR class request:
                               Return the relavent current probe data base on your frame index. As followingVGA frame size probe structure data.
uint8_tglProbeCtrl1[CX3_UVC_MAX_PROBE_SETTING] = {
0x00,0x00,                        /* bmHint : No fixed parameters */
0x01,                              /* Use 1st Video format index */
0x01,                              /* Use 1st Video frame index */
0x0A,0x8B,0x02,0x00, /* Desiredframe interval in 100ns */
0x00,0x00,                        /* Key frame rate in key frame/video frame units */
0x00,0x00,                        /* PFrame rate in PFrame / key frame units */
0x00,0x00,                        /* Compression quality control */
0x00,0x00,                        /* Window size for average bit rate */
0x00,0x00,                        /* Internal video streaming i/flatency in ms */
0x00,0x60,0x09,0x00,            /* Max video frame size in bytes */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x40, 0x00,0x00             /* No. of bytes device can rx in single payload: 32KB */
#else
/* UVC 1.1 Probe Control hasadditional fields from UVC 1.0 */
0x00, 0x90, 0x00,0x00,            /* No. of bytes device can rx in single payload: 32KB */
0x00, 0x60, 0xE3,0x16,             /*Device Clock */
0x00,                              /* Framing Information - Ignored for uncompressed format*/
0x00,                              /* Preferred payload format version */
0x00,                              /* Minimum payload format version */
0x00                               /* Maximum payload format version */
#endif
};
               SET_CUR class request:
                               Change your frame intervals from set_cur class request based on the selectprobe structure from host side.
               status = CyU3PUsbGetEP0Data(CX3_UVC_MAX_PROBE_SETTING_ALIGNED, glCommitCtrl,&readCount);// get set_cur class request data from host
      glCurrentFrameIndex = glCommitCtrl[3];//frame index
                    switch(glCurrentFrameIndex){
// change your probe
                    case 0x1:
                          glProbeCtrl1[2] = glCommitCtrl[2]; //change probe structure frame intervalsvalues.
                          glProbeCtrl1[3] = glCommitCtrl[3];
                          glProbeCtrl1[4] = glCommitCtrl[4];
                          glProbeCtrl1[5] = glCommitCtrl[5];
                          glProbeCtrl1[6] = glCommitCtrl[6];
                          glProbeCtrl1[7] = glCommitCtrl[7];
                          break;
Commit Stage:
               GET_CUR class request:
                               Return the relavent current commit data base on your frame index. As followingVGA frame size probe structure data.
uint8_t glProbeCtrl1[CX3_UVC_MAX_PROBE_SETTING]= {
0x00,0x00,                        /* bmHint : No fixed parameters */
0x01,                              /* Use 1st Video format index */
0x01,                              /* Use 1st Video frame index */
0xx,0xx,0xx,0xx /* Desired frameinterval in 100ns */ Need to be changed from your probe set_cur class request
0x00,0x00,                        /* Key frame rate in key frame/video frame units */
0x00,0x00,                        /* PFrame rate in PFrame / key frame units */
0x00,0x00,                        /* Compression quality control */
0x00,0x00,                        /* Window size for average bit rate */
0x00,0x00,                        /* Internal video streaming i/flatency in ms */
0x00,0x60,0x09,0x00,            /* Max video frame size in bytes */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x40, 0x00,0x00             /* No. of bytes device can rx in single payload: 32KB */
#else
/* UVC 1.1 Probe Control hasadditional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00,            /* No. of bytes device can rx in single payload: 32KB */
0x00, 0x60, 0xE3,0x16,            /* Device Clock */
0x00,                              /* Framing Information - Ignored for uncompressed format*/
0x00,                              /* Preferred payload format version */
0x00,                              /* Minimum payload format version */
0x00                               /* Maximum payload format version */
#endif
};
               SET_CUR class request:
                               Change your image sensor configuration as your expect frame rate and streamingthe video data as following code.
                    CyCx3UvcAppImageSensorSetVideoResolution (glCommitCtrl[3]);//your frame indexand frame interval

                    if (glIsApplnActive)
                    {
#ifdef CX3_DEBUG_ENABLED
                          CyU3PDebugPrint (4, "\n\rUSB Setup CB:Call AppSTOP1");
#endif
                          CyCx3UvcAppStop();
                    }

                    CyCx3UvcAppStart();










沙发
芯片IC去字笔| | 2015-12-21 15:58 | 只看该作者
辛苦了,谢谢分享!

使用特权

评论回复
板凳
gll123| | 2015-12-22 18:07 | 只看该作者
真的很赞~虽然看不懂USB~

使用特权

评论回复
地板
追逐~飞翔| | 2017-3-30 16:42 | 只看该作者
刚接触UVC,楼主能否告知,在UVC的拓展单元中,会有一项GUID,应该代表Extension Unit是遵循谁的协议,比如Logitech,这些资料应该从哪里获得呢???很多地方都没有搜到。

使用特权

评论回复
5
joezxd| | 2017-7-17 16:34 | 只看该作者
你好,我目前我在cx3上面调ov7251的sensor,在填probe setting参数中有一项是device clock,这里是指带的cx3设备clock吧,是否需要随着sensor换而修改?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

26

主题

61

帖子

19

粉丝