亲,“电路城论坛”已合并升级到更全、更大、更强的「新与非网」。了解「新与非网」
签到天数: 216 天
连续签到: 1 天
[LV.7]常住居民III
sudo apt-get install ipython python-opencv python-scipy python-numpy python-setuptools python-pip sudo pip install https://github.com/ingenuitas/SimpleCV/zipball/master sudo apt-get install python-pygame sudo apt-get install python-imaging
#!/usr/bin/env python from SimpleCV import * import SimpleCV from time import sleep #myCamera = Camera(prop_set={'width':320, 'height': 240}) myCamera =SimpleCV.Camera() myDisplay = Display(resolution=(320, 240)) while not myDisplay.isDone(): frame = myCamera.getImage() faces = frame.findHaarFeatures('face') if faces: 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." frame.save(myDisplay) sleep(.1)程序说明:myCamera =Camera(prop_set={'width':320,'height': 240}) #指定摄像头影像尺寸 myDisplay =Display(resolution=(320, 240)) #显示窗口大小 frame =myCamera.getImage() #获取视频流摄像头影像 faces =frame.findHaarFeatures('face') #寻找人脸 facebox=facelayer.centeredRectangle(face.coordinates(),facebox_dim) frame.addDrawingLayer(facelayer) #框出识别到的人脸并把图层放到画面上 print "Nofaces detected." #如果未检测到人脸打印信息步骤五:运行程序 这里如果识别到有人脸出现在摄像头范围内,程序会框出人脸,同时Python shell下会打印出具体位置,如果没有检测到人脸则会打印Nofaces detected。
下载资料失效了?点击此处告知管理员 > >
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
查看 »
手机版|小黑屋|与非网
GMT+8, 2024-11-19 06:38 , Processed in 0.114530 second(s), 18 queries , MemCache On.
苏公网安备 32059002001037号
Powered by Discuz! X3.4
Copyright © 2001-2024, Tencent Cloud.