以下內容為 2017/1/21 參加 Raspberry pi Camera + OpenCV Workshop 的重點紀錄(當時上課的主講為 sosorry@raspberrypi.com.tw)
由於環境已在上課前已經裝好了,因此只記錄部分操作方式。
本篇所有內容皆為課堂上及教材的東西
簡易操作
- 只預覽2秒(-t),不存檔
$ raspistill -t 2000
-
5秒後拍照(預設),檔案test.jpg(-o)
$ raspistill -o test.jpg
-
3秒後拍照,並編碼成png格式(-e),長640x寬480
$ raspistill -t 3000 -o test.png -e png -w 640 -h 480
-
看照片
$ gpicview test.jpg
-
leafpad 編輯器
$ leafpad
Chapter 01 安裝Xming 及下載程式範例
安裝Xming: https://sourceforge.net/projects/xming/
```
$ cd ~
$ curl http://sosorry.s3.amazonaws.com/raspberrypi/code/camera-opencv.tar.gz | tar xvz
```
Chapter 02 照相、錄影
$ cd ~/camera-opencv/02-picamera
Demo 拍照
$ python take_photo.py
Demo 錄影
$ python record_video.py
Chapter 03 串接網路服務(影像辨識)
$ cd ~/camera-opencv/03-imagga_web_service
- 申請帳號 : https://imagga.com/
- 取得授權 : https://imagga.com/profile/dashboard
- 串接 :
input:程式指定圖片的URL或是上傳圖檔
output : JSON 字串
Demo 圖像辨識
$ leafpad
- 修改 tag_file_url.py 中 queryString
$ python tag_file_url.py
Demo 雲端相機
$ python smart_camera.py
Chapter 04 色彩空間轉換
$ cd ~/camera-opencv/04-image_processing
- Demo HSV 及時調整
$ python hsv_value.py lena512rgb.png
-
Demmo Canny Edge Detection
$ python canny_edge_detect.py lena512rgb.png
Chapter 05 人臉偵測
$ cd ~/camera-opencv/05-face_detection
使用前先載入模組
$ sudo modprobe bcm2835-v4l2
-
Demo 人臉偵測
$ python image_face_detect.py abba.png haarcascade_frontalface_default.xml
-
Demo 讀取 Camera 並辨識
$ python camera_face_detect.py haarcascade_frontalface_default.xml