下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上php开发人脸识别的api接口作者:来源:互联网日期:2013-11-14 16:20:25 评论:( )阅读:1982在网上发现一个编写的人脸识别的API,试了一下还不错,这里推荐给大家,有兴趣的可以研究研究。首先,检测出三张输入图片中的Face。然后,使用这三个Face各自创建1个新的Person。这三个Person将构建一个新的Group以作为候选的识别库。最后,输入一张新Image,并在已构建的Group中识别这个新Image中的Face。创建新的Person待识别图片首先需要经过初步检测,找出图片中Face的位置及属性。然后,
2、再使用API中的Person管理创建新的Person。1234567891011121314151617181920212223242526272829303132333435/ the list of person_name to train and identify for$person_names = array("1", "2", "3");/ store the face_ids obtained by detection/detect API$face_ids =
3、;array();/ register new people, detect facesforeach ($person_names as $person_name) detect($api, $person_name, $face_ids);
4、0; /* * create new person, detect faces from person's image_url */function detect(&$api, $person_name, &$face_ids) / obtain photo_url to train $url = getTrainingUrl
5、($person_name); / detect faces in this photo $resu
6、lt = $api->face_detect($url); / skip errors if (empty($result->face) return false; / skip photo with multiple faces (we are not sure which face to train)
7、; if (count($result->face) > 1) return false; &
8、#160; / obtain the face_id $face_id = $result->face0->face_id; $face_ids = $face_id; / delete the person if exists $api->person_delete($p
9、erson_name); / create a new person for this face $api->person_create($person_name); / add face into new person $api->person_add_face($face_id, $person_name);构建新的Group注册一个新的Group,并将之前创建的Person加入这个Gr
10、oup。123456789101112131415161718/ the name of group for testing$group = "sample_group"/ generate a new group, add people into groupcreate_group($api, $group, $person_names);
11、160; /* * generate a new group with group_name, add all people into group */function create_group(&$api, $group_name, $person_names) / delete the group if exists $api
12、->group_delete($group_name); / create new group $api->group_create($group_name); / add new person into the group foreach ($person_names as $person_name)
13、; $api->group_add_person($person_name, $group_name);训练识别模型对刚创建的group,调用/train/identify来训练识别特征以待识别。(注意:/train/identify是一个异步方法,因此在调用train函数后我们需要等待训练完毕才能继续执行后续代码。)1234567891011121314151617181920212223242526272829/ generate training model for grouptrain($api, $group);
14、 /* * train identification model for group */function train(&$api, $group_name) / train model $session
15、60;= $api->train_identify($group_name); if (empty($session->session_id) / something went wrong, skip return false;
16、 $session_id = $session->session_id; / wait until training process done while ($session=$api->info_get_session($session_id) sleep(1);
17、 if (!empty($session->status) if ($session
18、->status != "INQUEUE") break; / done return true;识别新图中的Face在对新图中
19、的Face进行以上提及的检测,注册和训练之后,我们就可以在已构建Group中识别新图中出现的Face了:123456789101112131415161718192021222324252627282930/ finally, identify people in the groupidentify($api, $person_names0, $group); /
20、* * identify a person in group */function identify(&$api, $person_name, $group_name) / obtain photo_url to identify $url = getPhotoUrl($person_name);
21、; / recoginzation $result = $api->recognition_identify($url, $group_name);
22、 / skip errors if (empty($result->face) return false; / skip photo with multiple faces if (count($result->face) > 1) return false; $face = $result->face0; &
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 金融顾问资产配置评估表
- 初中数理化课程教师教育辅导绩效评定表
- 软件开发工程师代码质量和项目交付效率绩效考核表
- 运营经理数据监控绩效考评表
- 关于分析市场数据的回复函5篇范本
- 生产质量管理体系绩效评定表
- 跨境电商平台用户转化提升方案
- 体育俱乐部教练员运动员训练成绩与进步情况KPI考核表
- 企业员工培训需求分析与规划指导手册
- 医院医药领域腐败问题个人自查自纠报告
- 检验科试剂耗材精细化管理方案
- (正式版)DB4403∕T 481-2024 《电动自行车充换电柜消防安全要求》
- 物业维修管理流程及注意事项
- 2026年河南省高考物理试卷(含答案及解析)
- 2026年公路检测工程师《水运材料》模拟试题及答案
- 卡通风可爱宝宝生日周岁宴请模板
- 2026中国光纤在医疗领域的创新应用与市场前景报告
- QJLDH0122025氟化钠(电子级)
- 2.2.1+烯烃+说课课件-2025-2026学年高二下学期化学人教版必修3
- 直通线的制作
- 肾小球肾炎患者饮食管理方案
评论
0/150
提交评论