阿里云人脸身份证识别

# https://market.aliyun.com/products/57124001/cmapi00050254.html?spm=5176.2020520132.101.3.15a1721807SkgN#sku=yuncode44254000019 仅限企业
  • 照片清晰、曝光正常,人脸完整无遮挡、表情自然,脸部无过黑、过亮、光晕等情况,角度无太大偏差。
  • 分辨率不超过1920*1080(高*宽),至少640*480,推荐短边缩放到720像素,压缩率大于0.9。照片高大于宽,如果传入的照片宽大于高,可能会影响检测效果。
  • 照片大小:小于1 MB。

public
function ALiSlyface() { $host = "https://slyface.market.alicloudapi.com"; $path = "/post/faceidcard/compare"; $method = "POST"; $appcode = "你的code"; $headers = array(); array_push($headers, "Authorization:APPCODE " . $appcode); array_push($headers, "Content-Type" . ":" . "application/x-www-form-urlencoded; charset=UTF-8"); $url = Request::param('link'); $name = Request::param('name'); $idcard = Request::param('idcard'); $image = urlencode($url); $bodys = "idcard=$idcard&name=" . urlencode($name) . "&url=" . $image; $url = $host . $path; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头 //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$" . $host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $res = json_decode(curl_exec($curl), true); if($res['success'] == true ) { return success(Status::SUCCESS, '操作成功', [ "data" => $res ]); }else{ return error(Status::ERROR, '', [ "data" => $res ]); } }

 

posted @ 2023-11-02 18:41  现世中的素人  阅读(40)  评论(0编辑  收藏  举报