一.FAQ 1.判斷自己的攝像頭是否支持uvc標准 輸入lsusb //列出usb設備 [cpp] Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0c45:62f1 Microdia //攝像頭 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 1a40:0101 TERMINUS TECHNOLOGY INC. Bus 002 Device 003: ID 17ef:6025 Lenovo 更詳細的樹形圖lsusb -t [cpp] /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=musb-hdrc/1p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/4p, 480M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=musb-hdrc/1p, 480M |__ Port 1: Dev 4, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=, 480M |__ Port 1: Dev 4, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=, 480M |__ Port 1: Dev 4, If 2, Class=audio, Driver=snd-usb-audio, 480M |__ Port 1: Dev 4, If 3, Class=audio, Driver=snd-usb-audio, 480M lsusb -d 0c45:62f1 -v | grep "14 Video" 檢測設備屬性 [cpp] bFunctionClasss 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video bInterfaceClass 14 Video 顯示類似上面信息表示該攝像頭是支持uvc標准的 2.使能/關閉調試的trace打印信息 [cpp] echo 0xffff > /sys/module/uvcvideo/parameters/trace echo 0 > /sys/module/uvcvideo/parameters/trace 3.播放測試 [cpp] view plaincopy mplayer tv:// -tv fps=25 二.uvc類標准 1.下載標准協議地址 [cpp] http://www.usb.org/developers/devclass_docs 2.功能特性(翻譯) Each video function has a single VideoControl (VC) interface and can have several VideoStreaming (VS) interfaces 每個視頻有且僅有1個VideoControl (VC)接口和可有多個 VideoStreaming (VS) 接口 The VideoControl (VC) interface is used to access the device controls of the function whereas the VideoStreaming (VS) interfaces are used to transport data streams into and out of the function. VC接口用於設備功能控制,VS接口用於傳輸數據流進出 Video Interface Class Code(A.1 P171) 視頻接口類代碼 就是宏定義的USB_CLASS_VIDEO 總共有3種子類subclass 1.VideoControl Interface 視頻控制接口子類 2.VideoStreaming Interface 視頻數據流接口子類 3.Video Interface Collection 視頻接口集合子類 宏定義 [cpp] v /* A.2. Video Interface Subclass Codes */ #define UVC_SC_UNDEFINED 0x00 #define UVC_SC_VIDEOCONTROL 0x01 #define UVC_SC_VIDEOSTREAMING 0x02 #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03 Units provide the basic building blocks to fully describe most video functions ,A Unit has one or more Input Pins and a single Output Pin, Unit提供了基礎模塊來全面描述大部分的視頻功能,一個Unit可以由一個或多個輸入引腳和僅一個輸出引腳(這裡的每一個pin代表一個邏輯上的數據流)