[关闭]
@SiberiaBear 2015-05-11T03:22:41.000000Z 字数 1657 阅读 3187

simpleCV使用笔记

raspberryPi
固定地址:https://www.zybuluo.com/SiberiaBear/note/51383

注:由于最近不再搞树莓派摄像头,本文已停止更新 2015年5月11日



树莓派官方提供的拍照函数

这里的函数非常的不全面,旨作为我学习时学过的笔记,详细信息请参见树莓派官方指南-摄像头篇,更多情况下,请man一下就好,我对man的内容进行了简单的翻译

1. raspistill

说明:
Runs camera for specific time, and take JPG capture at end if requested

2. 之后的都没有用过,所以没有笔记

使用基本指令:

  1. raspistill -o image.jpg

参数:
-o --output: Output filename (to write to stdout, use '-o -'). If not specified, no file is saved
-w --width: Set image width
-h --height: Set image height
-t --timeout: Time (in ms) before takes picture and shuts down (if not specified, set to 5s)minimum 30ms, setting to 0 waits forever. 注:如果你设置成0,你会后悔的,相信我。

对于CSI接口的摄像头操作simpleCV

已知现在我还没有找到可以支持simpleCV支持CSI接口的资料,不排除我没好好找的原因,也由于个人能力问题,这样只能采取一种绕弯的方法来实现。
我是用树莓派做的,由上边我们知道一个函数raspistill,用这个函数就可以实现。
方法是:首先用该函数拍下一张照片(用subprocess调用),然后将照片读入。
该程序出现的问题有:
1. 图像拍照速度过慢
2. 脸部识别失败率高

以下例程是我参考资料编写的实现面部识别返回面部中部坐标的Python程序

  1. 1 import subprocess
  2. 2 from SimpleCV import Camera, Image
  3. 3 from time import sleep
  4. 4
  5. 5 filename = "face.jpg"
  6. 6 cmd = 'raspistill -w 960 -h 720 -o ' + filename + ' -t 100'
  7. 7 pid = subprocess.call(cmd, shell=True)
  8. 8
  9. 9
  10. 10
  11. 11 captureImg = Image(filename)
  12. 12
  13. 13 faces = captureImg.findHaarFeatures('face')
  14. 14 if faces:
  15. 15 for face in faces:
  16. 16 print "Face at: " + str(face.coordinates())
  17. 17 face.draw()
  18. 18 else:
  19. 19 print "No faces detected."
  20. 20
  21. 21 captureImg.save(filename)

找到了树莓派CSI接口的pinmap

还是谷歌大大给力:http://www.petervis.com/Raspberry_PI/Raspberry_Pi_CSI/raspberry-pi-csi-interface-connector-pinout.html

S5 Pin Name Purpose
1 Ground Ground
2 CAM1_DN0 DataLane0
3 CAM1_DP0 DataLane0
4 Ground Ground
5 CAM1_DN1 DataLane1
6 CAM1_DP1 DataLane1
7 Ground Ground
8 CAM1_CN MIPIClock
9 CAM1_CP MIPIClock
10 Ground Ground
11 CAM_GPIO
12 CAM_CLK
13 SCL0 I2C Bus
14 SDA0 I2C Bus
15 +3.3V Power
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注