這個折騰屬於既玩了,又做點有意義的事情。
基本參考:
www.rudiswiki.de/wiki/...bCamStream
此教程針對安裝了debian linux 的 dockstar 或者 pogoplug,以及其它設備
第一步,確定你的USB攝像頭能被支持
首先為系統安裝和視頻捕捉相關的包
代碼: |
apt-get install uvccapture
apt-get install libv4l-0
|
然後你可以插上你的usb camera到設備的USB口上,查詢 lsusb 應可以看到新插上的USB設備,類似
代碼: |
# lsusb
Bus 001 Device 005: ID 046d:09a4 Logitech, Inc. QuickCam E 3500
...
|
此外你可以查詢系統log
可以看到類似
代碼: |
...
usb 1-1.2: new high speed USB device using orion-ehci and address 5
uvcvideo: Found UVC 1.00 device USB2.0 PC CAMERA (18ec:299e)
uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround.
input: USB2.0 PC CAMERA as /devices/platform/orion-ehci.0/usb1/1-1/1-1.2/1-1.2:1.0/input/input1
|
的信息,這些信息裡要注意的是 UVC non compliance,如果有這樣的信息出現,說明攝像頭與UVC模式存在兼容問題,需要用到 YUYV 模式
要注意的是有些早期的攝像頭可能不被支持,要確定你的攝像頭是否被支持,主要的方法是運行 lsmod
如果能在輸出結果中找到類似
videodev xxxxx 1 uvcvideo
v4l1_compat xxxx 2 uvcvideo,videodev
的信息,恭喜,你的攝像頭可以被支持。
此外安裝 dov4l 包,可以查詢攝像頭的信息
代碼: |
apt-get install dov4l
dov4l -q
|
結果可能類似
代碼: |
dov4l v0.9, (C) 2003-2006 by folkert@vanheusden.com
Canonical name for this interface: USB2.0 PC CAMERA
Type of interface:
Can capture to memory
Number of radio/tv channels if appropriate: 1
Number of audio devices if appropriate: 0
Maximum capture width in pixels: 640
Maximum capture height in pixels: 480
Minimum capture width in pixels: 48
Minimum capture height in pixels: 32
Image size (x,y): 640, 480
The channel number: 0
The input name: Camera 1
Number of tuners for this input: 0
The input is a camera
The norm for this channel: 0
Brightness: 32896
Hue: 32896
Colour: 12850
Contrast: 31868
Whiteness: 17476
Depth: 16
Palette: Describe me
|
好了,確定了攝像頭被支持後,cheese! 給自己拍張照試試
或者
如果你的攝像頭存在UVC兼容問題,請使用 uvccapture -m
照片被存在了當前目錄下,文件名為snap.jpg,傳到自己的計算機看看(通過winscp或者filezilla,或者拷貝到samba共享目錄下),如果你能成功打開並看到圖像,恭喜,你已經成功了第一步。
uvccapture 的更多參數請參考:
www.digipedia.pl/man/d...capture.1/
第二步,輸出視頻流!
靜態拍照沒問題了,下一步我們就輸出視頻流,方案有兩個
1. mjpeg-streamer (輕量級)
2. VLC (重量級)
先嘗試 mjpeg-streamer,這個東東需要編譯源碼,就比較啰噤X耍迷諭嫌腥頌峁┝薬rmel平台的可執行文件(如果是386平台,請下載安裝
sourceforge.net/projec...download)
我們先偷懶,下載
mjpg-streamer-mini2440...-r6.tar.gz
代碼: |
mkdir mjpg
cd mjpg
wget http://mjpg-streamer-mini2440.googlecode.com/files/mjpg-streamer-mini2440-bin-r6.tar.gz
tar xzf mjpg-streamer-mini2440-bin-r6.tar.gz
./mjpg_streamer --help
|
./mjpg_streamer --help 會顯示mjpeg-streamer的幫助。
mjpg_streamer 更詳細的文檔,請參考
skillfulness.blogspot....ation.html
這個版本不支持設定幀速率,默認是每秒5幀,少是少了點。
好了,現在我們可以輸出視頻流了,如果你的攝像頭存在UVC兼容問題,請執行
./start_uvc_yuv.sh
否則請執行
./start_uvc.sh
然後你就可以在瀏覽器中輸入
your_device_ip:8080/?action=stream 觀看視頻流了。
你還可以在你的計算機上用 vlcplayer 打開該視頻流,邊觀看邊錄像。
用瀏覽器訪問
your_device_ip:8080 會看到 mjpeg-streamer 形成的一個小網站,可以讓你看到靜態照片或者視頻流,並教你如何用javascript調用視頻流。
mjpeg-streamer 形成的網站

請點擊圖片查看原圖uvccapture 輸出樣張

請點擊圖片查看原圖