欢迎来到天天文库
浏览记录
ID:39467262
大小:61.50 KB
页数:4页
时间:2019-07-04
《php开发人脸识别的api接口》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、php开发人脸识别的api接口作者: 来源:互联网 日期:2013-11-1416:20:25 收藏 评论:( 0 ) 阅读:1982在网上发现一个PHP编写的人脸识别的API,试了一下还不错,这里推荐给大家,有兴趣的可以研究研究。首先,检测出三张输入图片中的Face。然后,使用这三个Face各自创建1个新的Person。这三个Person将构建一个新的Group以作为候选的识别库。最后,输入一张新Image,并在已构建的Group中识别这个新Image中的Face。创建新的Person待识别图片首先需要经过初步检测,找出图片中F
2、ace的位置及属性。然后,再使用API中的Person管理创建新的Person。1234567891011121314151617181920//thelistofperson_nametotrainandidentifyfor$person_names = array("1", "2", "3");//storetheface_idsobtainedbydetection/detectAPI$face_ids = array();//registernewpeople,detectfacesforeach ($person_names
3、as $person_name) detect($api, $person_name, $face_ids); /* * createnewperson,detectfacesfromperson'simage_url */function detect(&$api, $person_name,&$face_ids){ //obtainphoto_urltotrain $url =getTrainingUrl($person_name);
4、 //detectfacesinthisphoto $result = $api->face_detect($url); //skiperrors if (empty($result->face)) return false; //skipphotowithmultiplefaces(wearenotsurewhichfacetotrain) if (count($result->face)>1) return false;
5、 //obtaintheface_id $face_id = $result->face[0]->face_id; $face_ids[]= $face_id; //deletethepersonifexists212223242526272829303132333435 $api->person_delete($person_name); //createanewpersonforthisface $api->person_create(
6、$person_name); //addfaceintonewperson $api->person_add_face($face_id, $person_name);}构建新的Group注册一个新的Group,并将之前创建的Person加入这个Group。1234567891011//thenameofgroupfortesting$group = "sample_group";//generateanewgroup,addpeopleintogroupcreate_group($api, $group, $person_n
7、ames); /* * generateanewgroupwithgroup_name,addallpeopleintogroup */function create_group(&$api, $group_name, $person_names){12131415161718 //deletethegroupifexists $api->group_delete($group_name); //createnewgroup $api->group_create($
8、group_name); //addnewpersonintothegroup foreach ($person_names as $person_name) $ap
此文档下载收益归作者所有