Thinkphp 匹配人脸
1.首先呢,肯定是去百度申请人脸接口权限
2.然后呢,后台创建人脸应用 获取APPID、 Apikey、 SecretKey
3.再然后呢,去下载官方demo,把该改的改了,该删的删了,整合成一个face的扩展类
4.再再然后呢,把face 放在vendor下面就OK了
5.最后呢,我知道你肯定不知道那些改删哪些该改,加我qq 229435572 备注 face 找我要face扩展类把 O(∩_∩)O哈哈~
下面是一个简单的人脸年龄测试,其他操作具体可见官方文档,不用怕,官方文档还是挺详细的
public function faceCheck() {
Vendor('face.AipFace');
#后台申请的A K 和 S
$APPID = '去申请';
$Apikey = '去申请';
$SecretKey = '去申请';
$client = new \AipFace($APPID, $Apikey, $SecretKey);
$image = "http://www.vikily.com:8765/statics/Admin/img/test.jpg";
$imageType = "URL";
// 调用人脸检测
$client->detect($image, $imageType);
// 如果有可选参数
$options = array();
$options["face_field"] = "age";
$options["max_face_num"] = 2;
$options["face_type"] = "LIVE";
// 带参数调用人脸检测
$result = $client -> detect($image, $imageType, $options);
dump($result);
}
返回信息:
Array
(
[error_code] => 0
[error_msg] => SUCCESS
[log_id] => 5510199948905
[timestamp] => 1533286267
[cached] => 0
[result] => Array
(
[face_num] => 1
[face_list] => Array
(
[0] => Array
(
[face_token] => 908ad0f2bcf04f27e0b41652d805af91
[location] => Array
(
[left] => 212.8435516
[top] => 160.4919739
[width] => 304
[height] => 286
[rotation] => 4
)
[face_probability] => 1
[angle] => Array
(
[yaw] => 1.442859173
[pitch] => 17.65565109
[roll] => 4.590346813
)
[age] => 23
)
)
)
)
还不会,有大招,关注下方公众号直接提问就可以了哈


浙公网安备 33010602011771号