ROS学习--人脸识别NODE
2016-06-21 12:31
561 查看
说明
所用的人脸识别为faceplusplus的服务准备
先安装摄像头,我在树莓派上实验,所用的也是树莓派专用的摄像头。摄像头具体安装可以见http://shumeipai.nxez.com/2013/10/07/raspberry-pi-to-install-the-camera-module.html
注意插线的时候别插反了就可以。
安装好摄像头的硬件之后,需要修改树莓派的配置,打开摄像头。
$ sudo raspi-config选择其中的Enable Camera按照提示操作,注意,树莓派打开摄像头的配置之后,需要重启,这个在退出raspi-config之前会有提示。
安装好之后可以测试可以拍张照片测试一下。命令如下
$ raspistill -o image.jpg -t 1000-o 表示输出的文件名
-t 表示拍照的延时,如果不加,默认的延时时间为5秒。
人脸识别也应该是广播的形式,但是我们可以先用服务的方式实现。
关于视频还有一个Python的包picamera,文档在 http://picamera.readthedocs.org/但我这里并没有使用。
在人脸识别之前,还需要在faceplusplus自己的应用上做一些准备工作,我使用faceplusplus的hello.py其中的代码改的。
# 首先,导入SDK中的API类 from facepp import API from facepp import File api = API(API_KEY, API_SECRET) #创建一个group用来添加人脸 api.group.create(group_name = 'ry_robot_001') #探测人脸并在这个group中添加person result = api.detection.detect(img = File(filepath), mode = 'oneface') face_id = result['face'][0]['face_id'] api.person.create(person_name = name, group_name = 'ry_robot_001', face_id = face_id) #对这个group进行训练 result = api.recognition.train(group_name = 'ry_robot_001', type = 'all') session_id = result['session_id'] # 等待训练完成 while True: result = api.info.get_session(session_id = session_id) if result['status'] == u'SUCC': print_result('Async train result:', result) break time.sleep(1) # 识别未知脸部图片 result = api.recognition.recognize(img = File(TARGET_IMAGE), group_name = 'ry_robot_001') print_result('Recognize result:', result) # 当然还可以删除创建的group和person #api.group.delete(group_name = 'ry_robot_001') #api.person.delete(person_name = name_list )
这里的代码是说明,node的相关代码已经提交到github,地址:https://github.com/roboyun/ros_afr
备注
关于视频摄像头实时转播。先启动客户端,将netcat的数据流发送到mplayer上,fps当小于40的时候,会有非常明显的延时
nc -l 5001 | mplayer -fps 60 -cache 1024 -在树莓派上的命令
raspivid -w 960 -h 540 -t 999999 -o - | nc 192.168.1.2 5001mplayer 播放视频过程中截图的代码,截图可用于人脸识别。
import time import subprocess #cmd = 'mplayer -slave -quiet -vf screenshot a.mp4' cmd = 'mplayer -quiet -vf screenshot a.mp4' #print cmd.split() p = subprocess.Popen(cmd.split(),shell=False,stdout=subprocess.PIPE,stdin=subprocess.PIPE) while True: time.sleep(2) print 'screen shot' p.stdin.write('s')
相关文章推荐
- 收集的ROS防火墙脚本
- C#实现控制摄像头的类
- 微信公众平台开发教程(四) 实例入门:机器人回复(附源码)
- 树莓派中python获取GY-85九轴模块信息示例
- opencv 做人脸识别 opencv 人脸匹配分析
- Android 开发随手笔记之使用摄像头拍照
- asp.net(c#)捕捉搜索引擎蜘蛛和机器人
- C#实现调用本机摄像头实例
- 使用图灵api创建微信聊天机器人
- 安卓(Android)聊天机器人实现代码分享
- 人脸识别测颜值、测脸龄、测相似度微信接口
- unity3d调用手机或电脑摄像头
- AngularJS中使用HTML5手机摄像头拍照
- 使用Python简单的实现树莓派的WEB控制
- Python中使用摄像头实现简单的延时摄影技术
- 在树莓派2或树莓派B+上安装Python和OpenCV的教程
- 让树莓派变成你的家庭防火墙
- 什么是android(What Is Android?)
- Raspberry PI 512M 入手