一、準備硬體:
- 已安裝好的ev3dev主機
- 羅技c270webcam
- 可支援外接電源的usb hub
二、參考資料:
- Adding a Webcam to EV3 (EV3DEV)
- mjpg-streamer GITHUB
- Secure Webcam streaming with MJPG-Streamer on a Raspberry Pi
- First-person view and remote control with LEGO Mindstorms EV3
- LEGO MovieMaker USB Camera with EV3 and ev3dev
- OpenCV Python + EV3DEV + Webcam
三、安裝套件:
sudo apt-get update
sudo apt-get install libv4l-dev libjpeg62-turbo-dev subversion imagemagick
上述的libjpeg62-turbo-dev套件,原mjpg-streamer GITHUB作者是採用libjpeg8-dev
libjpeg62-turbo-dev及libjpeg8-dev只能擇一安裝
我是採用libjpeg62-turbo-dev
安裝cmake、gcc、g++
sudo apt-get install cmake gcc g++
mjpg-streamer簡單安裝法(參考:https://github.com/jacksonliam/mjpg-streamer)
git clone https://github.com/jacksonliam/mjpg-streamer.git
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd ~/mjpg-streamer/mjpg-streamer-experimental
make
sudo make install
四、執行streamer
主程式為mjpg-streamer,安裝位置在/usr/local/bin/,程式資料夾位於/usr/local/lib/mjpg-streamer
程式執行的參數
mjpg_streamer -i "input_uvc.so --help"
input_uvc.so 主要定義輸入的影像解析度、畫質、每秒的frame數
mjpg_streamer -o "output_http.so --help"
output_http.so是定義mjpg-streamer 的www位置、port、是否要輸入密帳才能進入http等
sudo /usr/local/bin/mjpg_streamer -i "/usr/local/lib/mjpg-streamer/input_uvc.so -n -f 10 -r 1280x720" -o "/usr/local/lib/mjpg-streamer/output_http.so -p 8085 -w /usr/local/share/mjpg-streamer/www"
打開瀏覽器連入http://ev3dev主機IP:8085,若順利應該可以看到webcam捉到的畫面
五、也可以使用VideoLAN以視訊串流方式播放
- 打開videolan->媒體->開始網路串流
- 將MJPG-Streamer 網頁中的VideoLAN內http://xxx.xxx.xxx.xxx:8085/?action=stream 複製,貼到網址列
- 若順利的話,應該就能捉到串流影像