TA的每日心情 | 奋斗 2022-10-13 10:27 |
---|
签到天数: 216 天 连续签到: 1 天 [LV.7]常住居民III
|
前面一直在赶其他事情,所以没及时更新帖子,也只是抽晚上赶下进度,如果要是能把试用推迟到一个星期就好了,这里简单对前面进行一个小结,并通过前面的学习,简单利用TigerBoard开发板模拟下人脸检测门禁系统,以继电器开关带代替门禁上电磁锁的开关。
硬件要求:
1.TigerBoar开发板
2. USB免驱摄像头
3. 继电器
4. 杜邦线若干
5. LED灯
软件要求:
1. Python环境
2. RPI.GPIO库
3. opencv2.4.9及相关依赖包
4. simpleCV函数库
开发环境:
1.Gobian
工程代码:
#!/usr/bin/env python
# windworld
from SimpleCV import *
from time import sleep
import RPi.GPIO as gpio # Include the RPi.GPIO library as gpio.
import time # Include the Python time functions.gpio.setmode(gpio.BOARD) # Set mod as BOARD, which means to use the numbering from the physical layout.
myCamera = Camera(prop_set={'width':320, 'height': 240})
myDisplay = Display(resolution=(320, 240))
while not myDisplay.isDone():
frame = myCamera.getImage()
faces = frame.findHaarFeatures('face')
if faces:
gpio.setup(33, gpio.OUT) # Set pin 33 on J3 to be an output.
gpio.output(33, gpio.HIGH) # Set pin 33 on J3 as high.
for face in faces:
print "Face at: " + str(face.coordinates())
facelayer = DrawingLayer((frame.width,frame.height))
w=face.width()
h=face.height()
print "x:"+str(w)+" y:"+str(h)
facebox_dim = (w,h)
facebox = facelayer.centeredRectangle(face.coordinates(),facebox_dim)
frame.addDrawingLayer(facelayer)
frame.applyLayers()
else:
print "No faces detected."
gpio.setup(33, gpio.OUT) # Set pin 33 on J3 to be an output.
gpio.output(33, gpio.LOW) # Set pin 33 on J3 as high.
frame.save(myDisplay)
sleep(.1)
PS:程序说明可以参考前面帖子,这里只是进行了代码整合
运行效果
摄像头水平,未检测到本人脸部,33pin低电平,所以灯未亮
摄像头朝上对准脸部,检测到本人,33pin高电平,所以灯亮
总结:TigerBoard开发板从年初收到,到现在算是也玩了有一段时间。从硬件性能上来说,相比目前市场上其他类似板子TigerBoard还算是非常不错,而且兼容树莓派管脚,支持RSP.GPIO库很是方便。但是可参考的资料还是有所欠缺,不过还好技术支持比较给力,能够及时解决遇到的问题,希望后期能用更多的资料,同时也希望大家一起多多分享自己关于TigerBoard开发板的学习心得。后面继续更新!!
|
|