开发者社区> 开发与运维> 正文

阿里云新版人脸识别 PHP 使用示例教程

简介: 本篇博客是对前面多语言开发阿里云新版人脸识别的续,主要介绍使用PHP SDK调用人脸识别的接口。

概述

本篇博客是对前面多语言开发阿里云新版人脸识别的续,主要介绍使用PHP SDK调用人脸识别的接口。

操作步骤

1、SDK安装 openapi-sdk-php-client

composer require alibabacloud/client

2、Code Sample

<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

require_once 'vendor\autoload.php';

// access_key_id, access_key_secret  获取参考链接:https://yq.aliyun.com/articles/693979?spm=a2c4e.11155435.0.0.319326a2bKJ90g
AlibabaCloud::accessKeyClient('********','********')->asDefaultClient();

class FaceAPIDemo{

/**
* DetectFace API 人脸检测定位
* 
* @param string $imageUrl 待检测人脸图片URL
*/
function DetectFace($imageUrl){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('DetectFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('ImageUrl', $imageUrl)
        ->request();
        
        print($result); // 输出结果
        } catch (ClientException $exception) {
            print_r($exception->getErrorMessage());
        } catch (ServerException $exception) {
            print_r($exception->getErrorMessage());
        }
    }


/**
 * GetFaceAttribute API 人脸属性识别
 * 
 * @param string $imageUrl 待检测人脸图片URL
 */
function GetFaceAttribute($imageUrl){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('GetFaceAttribute')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('ImageUrl', $imageUrl)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * VerifyFace API 人脸对比
 * 
 * @param string $imageUrl_1
 * @param string $imnageUrl_2
 */
function VerifyFace($imageUrl_1, $imageUrl_2){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('VerifyFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('ImageUrl1', $imageUrl_1)
        ->setQueryParameters('ImageUrl2', $imageUrl_2)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * AddFace接口用于向人脸库中添加人脸
 * 
 * @param string $groupName 添加人脸的分组
 * @param string $person 添加人脸的姓名
 * @param string $image 添加人脸的编号
 * @param string $imageUrl 添加人脸图片的URL 
 */
function AddFace($groupName, $person, $image, $imageUrl){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('AddFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('Group', $groupName)
        ->setQueryParameters('Person', $person)
        ->setQueryParameters('Image', $image)
        ->setQueryParameters('ImageUrl', $imageUrl)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * DeleteFace接口用于从人脸库中删除人脸
 * 
 * @param string $groupName 删除人脸所在的分组
 * @param string $person 删除人脸的姓名
 * @param string $image 删除的人脸编号
 */
function DeleteFace($groupName, $person, $image){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('DeleteFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('Group', $groupName)
        ->setQueryParameters('Person', $person)
        ->setQueryParameters('Image', $image)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * ListFace接口用于列举注册库中的人脸
 * 
 * @param string $groupName
 */
function ListFace($groupName){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('ListFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('Group', $groupName)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * ListGroup接口用于列举人脸组
 */
function ListGroup(){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('ListGroup')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

/**
 * RecognizeFace接口用于查找注册库中的人脸
 * 
 * @param string $groupName 识别的组
 * @param string $recognizeFaceImageUrl 图像URL
 */
function RecognizeFace($groupName, $recognizeFaceImageUrl){
    try {
        $result = AlibabaCloud::rpc()
        ->product('FaceAPI')
        ->version('2018-12-03')
        ->action('RecognizeFace')
        ->method('POST')
        ->host('face.cn-shanghai.aliyuncs.com')
        ->regionId('cn-shanghai')
        ->setAcceptFormat('json')
        ->setQueryParameters('Group', $groupName)
        ->setQueryParameters('ImageUrl', $recognizeFaceImageUrl)
        ->request();
        
        print($result); // 输出结果
    } catch (ClientException $exception) {
        print_r($exception->getErrorMessage());
    } catch (ServerException $exception) {
        print_r($exception->getErrorMessage());
    }
}

}


$ClientDemo = new FaceAPIDemo;

$imageUrl_1 = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1563695836469&di=0f2344bc0c8ffbdb69ee2b7cd50972f1&imgtype=0&src=http%3A%2F%2Fwww.jd-tv.com%2Fuploads%2Fallimg%2F170926%2F30-1F926094918.jpg';
$imageUrl_2 = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559655604338&di=ee3d8fb39f6e14a21852a4ac3f2c5a14&imgtype=0&src=http%3A%2F%2Fc4.haibao.cn%2Fimg%2F600_0_100_0%2F1473652712.0005%2F87c7805c10e60e9a6db94f86d6014de8.jpg";
$recognizeFaceImageUrl = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559655604335&di=7b540d703955aed6d235752589aee34a&imgtype=0&src=http%3A%2F%2Fphotocdn.sohu.com%2F20140317%2FImg396736687.jpg";

$groupName = "defaultPHPDemo1";
$person = "LiuYifei";
$image_1 = "photo1";
$image_2 = "photo2";

// print('Base function Demo');
echo 'Base function Demo<br>';
$ClientDemo->DetectFace($imageUrl_1);
echo '<br>------------------------------------------<br>';
$ClientDemo->GetFaceAttribute($imageUrl_2);
echo '<br>------------------------------------------<br>';
$ClientDemo->VerifyFace($imageUrl_1, $imageUrl_2);
echo '<br>------------------------------------------<br>';
echo '1:N function Demo<br>';

$ClientDemo->AddFace($groupName, $person, $image_1, $imageUrl_1);
$ClientDemo->AddFace($groupName, $person, $image_2, $imageUrl_2);
echo '<br>------------------------------------------<br>';

$ClientDemo->ListFace($groupName);
echo '<br>------------------------------------------<br>';

$ClientDemo->ListGroup();
echo '<br>------------------------------------------<br>';

$ClientDemo->RecognizeFace($groupName, $recognizeFaceImageUrl);
echo '<br>------------------------------------------<br>';

$ClientDemo->DeleteFace($groupName, $person, $image_1);
echo '<br>------------------------------------------<br>';

$ClientDemo->ListFace($groupName);
?>

3、运行结果

Base function Demo
{"Data":{"landmark":[269.24758911132812,75.156051635742188,309.4066162109375,83.492401123046875,291.95159912109375,68.32568359375,290.14346313476562,75.288475036621094,275.90603637695312,70.319343566894531,283.75555419921875,67.893951416015625,299.71075439453125,71.024147033691406,306.29025268554688,75.928268432617188,276.23892211914062,74.843666076660156,283.21786499023438,74.323966979980469,296.81741333007812,77.387138366699219,303.0400390625,80.586746215820312,329.451416015625,92.962821960449219,360.74655151367188,115.38473510742188,351.37371826171875,94.346420288085938,347.88836669921875,100.46926116943359,336.53253173828125,89.276222229003906,344.42013549804688,90.437255859375,356.7987060546875,100.19455718994141,360.189697265625,107.40948486328125,335.68844604492188,95.32562255859375,342.09222412109375,97.170967102050781,353.29949951171875,104.33158874511719,357.24386596679688,109.70858764648438,275.20828247070312,88.702957153320312,297.89642333984375,97.662940979003906,278.4547119140625,87.8427734375,281.80853271484375,87.67181396484375,285.14581298828125,88.045280456542969,288.3438720703125,89.074775695800781,291.38003540039062,90.513786315917969,294.24282836914062,92.272270202636719,296.74557495117188,94.512748718261719,277.26690673828125,91.087905883789062,279.89337158203125,92.8275146484375,282.71017456054688,94.237747192382812,285.614990234375,95.456985473632812,288.617431640625,96.410232543945312,291.6510009765625,97.26043701171875,294.75155639648438,97.816993713378906,325.13623046875,110.33549499511719,345.68753051757812,119.67900085449219,327.97607421875,109.08544921875,331.08062744140625,109.32014465332031,334.08670043945312,110.13468170166016,336.9962158203125,111.24644470214844,339.76797485351562,112.66738891601562,342.24386596679688,114.55679321289062,344.3099365234375,116.88607788085938,326.71929931640625,112.92459106445312,328.855224609375,115.08128356933594,331.30126953125,116.87850952148438,333.87762451171875,118.4835205078125,336.71099853515625,119.57112884521484,339.6751708984375,120.22142028808594,342.70953369140625,120.26644134521484,311.9210205078125,103.40117645263672,306.65936279296875,118.44577026367188,309.3336181640625,110.83119201660156,301.71621704101562,129.02568054199219,286.83261108398438,125.05934143066406,314.39862060546875,137.02812194824219,273.32730102539062,145.12872314453125,309.71231079101562,160.97463989257812,278.32568359375,146.40306091308594,305.15988159179688,158.29728698730469,295.57345581054688,144.12054443359375,292.23159790039062,141.57420349121094,299.99911499023438,145.00601196289062,282.43362426757812,141.6441650390625,306.31008911132812,152.15667724609375,277.61135864257812,142.69940185546875,287.32510375976562,141.02316284179688,303.56137084960938,148.2225341796875,308.76480102539062,156.28082275390625,288.04281616210938,159.41645812988281,278.74847412109375,154.20783996582031,298.75405883789062,162.62725830078125,275.46533203125,150.01351928710938,283.282958984375,157.01313781738281,293.322021484375,161.27685546875,304.34457397460938,162.54356384277344,292.68966674804688,150.13851928710938,292.36453247070312,150.19456481933594,285.73855590820312,147.37432861328125,285.31869506835938,148.41230773925781,299.47579956054688,153.37799072265625,298.8055419921875,154.16500854492188,282.05441284179688,146.72181701660156,281.78817749023438,147.52586364746094,289.19363403320312,148.80339050292969,288.89260864257812,149.100341796875,296.1036376953125,151.71966552734375,295.74795532226562,151.91595458984375,302.42306518554688,155.715576171875,301.86788940429688,156.40838623046875,247.46833801269531,88.043235778808594,363.85662841796875,137.81517028808594,277.2391357421875,190.51713562011719,236.92835998535156,145.33152770996094,334.41033935546875,185.22996520996094,239.58412170410156,115.52323150634766,351.20584106445312,162.83509826660156,252.22189331054688,173.25889587402344,306.05673217773438,195.89654541015625],"pose":[1.6183135509490967,15.306655883789062,22.176498413085938],"face_prob":[1.0],"request_id":"99775EF3-1FA6-4305-8FB2-37B10E4DFA6A","errno":0,"face_num":1,"iris":[289.12600708007812,92.507186889648438,4.651268482208252,334.61651611328125,114.15340423583984,4.651268482208252],"landmark_num":105,"face_rect":[242,45,122,144]},"RequestId":"99775EF3-1FA6-4305-8FB2-37B10E4DFA6A","Success":true}
------------------------------------------
{"Data":{"expression":[0],"dense_fea":[0.032727491110563278,-0.0082056038081645966,-0.029683364555239677,-0.0096274437382817268,-0.0062350276857614517,-0.0026448068674653769,-0.0067025707103312016,-0.042322065681219101,-0.032813072204589844,0.066940806806087494,-0.031563118100166321,-0.034121245145797729,0.032720323652029037,0.018700320273637772,0.040912583470344543,-0.013406608253717422,0.0017285562353208661,-0.016166945919394493,0.014212021604180336,0.010660518892109394,0.0084707122296094894,0.036787349730730057,0.0049957362934947014,-0.038922004401683807,0.0094015710055828094,0.0068221860565245152,-0.010362580418586731,0.06648186594247818,0.056468170136213303,-0.0043498380109667778,-0.022770209237933159,-0.014392802491784096,0.0077355997636914253,0.010461430065333843,-0.0079089095816016197,0.0020622825250029564,-0.041936200112104416,-0.044677924364805222,0.047330934554338455,-0.026108806952834129,-0.027621025219559669,0.0089288912713527679,-0.0065221991389989853,0.01732107438147068,-0.014468864537775517,0.024791350588202477,-0.020587733015418053,0.010181466117501259,0.036107007414102554,-0.032575067132711411,-0.026263736188411713,0.019539019092917442,-0.021295515820384026,0.010360166430473328,0.0016431875992566347,0.06313817948102951,0.042572718113660812,0.03725554421544075,-0.028425950556993484,-0.0089646400883793831,-0.061609700322151184,-0.0052227862179279327,-0.046197503805160522,-0.0054872077889740467,0.0029128233436495066,0.0020342939533293247,-0.046985208988189697,-0.026900548487901688,0.027349323034286499,-0.023508371785283089,0.0081287696957588196,0.027452105656266212,0.02855827659368515,-0.013083036988973618,-0.0035784775391221046,-0.018154701218008995,0.0083623556420207024,-0.0092102736234664917,-0.0089603736996650696,-0.032652441412210464,0.023708861321210861,-0.025407390668988228,-0.03506232425570488,-0.04786122590303421,-0.014871174469590187,0.012019175104796886,0.010737509466707706,-0.046481531113386154,-0.0056934473104774952,0.044521350413560867,-0.011273238807916641,0.046886146068572998,0.022450640797615051,-0.033565357327461243,-0.011120734736323357,0.0014232759131118655,-0.058901343494653702,0.020882824435830116,-0.010866828262805939,0.0090104863047599792,-0.00057380337966606021,-0.014375720173120499,-0.053915120661258698,-0.0061579332686960697,0.019850153475999832,-0.033566128462553024,-0.013014300726354122,-0.052159529179334641,-0.021410537883639336,-0.0085521265864372253,-0.049211077392101288,0.067557960748672485,0.035185251384973526,-0.022767061367630959,-0.043442249298095703,-0.0052431798540055752,0.015893742442131042,0.045664872974157333,-0.031942319124937057,-0.00074889359530061483,0.046309478580951691,0.00091387249995023012,0.063510186970233917,-0.0079166032373905182,-0.0045268642716109753,-0.015213570557534695,0.021366933360695839,-0.0077703846618533134,-0.064481168985366821,-0.012182059697806835,0.063210204243659973,0.084716908633708954,-0.0050023403018712997,0.038193397223949432,-0.015867570415139198,0.01632281020283699,-0.0023937516380101442,-0.04451240599155426,0.033330444246530533,0.022885987535119057,-0.032544106245040894,0.03949272632598877,0.024744128808379173,-0.01038001012057066,0.05127725750207901,-0.007178653497248888,-0.010036447085440159,-0.070052273571491241,0.031381193548440933,0.014356805011630058,0.0029588059987872839,-0.0014321212656795979,0.024616777896881104,0.030502144247293472,0.03151397779583931,-0.054944872856140137,0.030372882261872292,-0.0035075908526778221,0.016011824831366539,-0.018013752996921539,0.014645944349467754,0.033703472465276718,0.020615382120013237,0.027796020731329918,-0.031960692256689072,0.042153723537921906,-0.030343839898705482,-0.02333701029419899,0.0036092991940677166,-0.022617140784859657,-0.044740431010723114,0.0068169734440743923,0.084661900997161865,-0.0082268845289945602,0.040676828473806381,0.019026700407266617,-0.027249863371253014,-0.029363946989178658,0.015378783456981182,-0.0024228759575635195,-0.022562388330698013,-0.04174315556883812,0.024250801652669907,-0.0094145471230149269,-0.05077781155705452,0.039274528622627258,-0.024050261825323105,0.042341619729995728,-0.026512054726481438,0.0081801777705550194,-0.0082026226446032524,-0.020809710025787354,-0.026034515351057053,0.012876772321760654,-0.011858414858579636,0.041344195604324341,-0.024697611108422279,0.015826383605599403,0.029146991670131683,0.00238022580742836,0.023530831560492516,0.0072940695099532604,0.027438625693321228,0.028963340446352959,0.024631103500723839,0.016460182145237923,-0.065476454794406891,0.042786069214344025,0.0271168053150177,-0.057292800396680832,0.043653130531311035,0.074018895626068115,-0.0091790929436683655,-0.014613390900194645,0.0022603068500757217,-0.00019762525334954262,0.0049971179105341434,-0.049047805368900299,0.023501202464103699,-0.017124656587839127,-0.0048491908237338066,-0.040060512721538544,0.030361125245690346,0.015514104627072811,-0.053992427885532379,0.052400439977645874,-0.027191024273633957,0.058834806084632874,0.036906398832798004,-0.014876607805490494,-0.051117785274982452,-0.052880581468343735,-0.019887847825884819,0.047327734529972076,-0.00016945738752838224,-0.018038613721728325,-0.011923404410481453,-0.054329086095094681,0.011504023335874081,-0.0017099310643970966,0.029220625758171082,-0.064924940466880798,-0.0076835337094962597,0.0060995211824774742,-0.0068181096576154232,-0.035507075488567352,-0.038002591580152512,-0.0012365642469376326,-0.030401742085814476,0.037892065942287445,-0.029295492917299271,0.002066844841465354,-0.040761590003967285,0.027784306555986404,0.0038503867108374834,0.014547655358910561,-0.050277773290872574,0.028280757367610931,-0.039480000734329224,0.038627125322818756,-0.0032416451722383499,0.007306195329874754,0.027227476239204407,-0.0028274916112422943,0.025762917473912239,-0.0031099556945264339,-0.06467244029045105,-0.046773802489042282,0.032679948955774307,-0.018184738233685493,-0.024781227111816406,-0.0069784428924322128,0.00089093140559270978,0.062452122569084167,0.044173218309879303,0.0066016726195812225,-0.072789773344993591,0.023462163284420967,-0.016921607777476311,0.017385445535182953,-0.013915834948420525,0.0025634875055402517,-0.041091151535511017,-0.011095141060650349,-0.027008412405848503,0.038381148129701614,-0.048599909991025925,-0.0063493824563920498,-0.053502358496189117,0.026816114783287048,-0.033505089581012726,-0.022248184308409691,-0.024954341351985931,-0.044203903526067734,-0.026957899332046509,0.043298076838254929,0.028161212801933289,0.029459306970238686,0.037935122847557068,0.0065484964288771152,-0.044354118406772614,-0.07473040372133255,0.039553165435791016,0.0095864236354827881,-0.059480719268321991,-0.047296062111854553,0.011953113600611687,-0.010029276832938194,-0.014672596007585526,-0.019205963239073753,0.0020607230253517628,-0.019253106787800789,-0.0094370609149336815,0.051314584910869598,-0.029539678245782852,-0.018402170389890671,-0.039998263120651245,-0.0085534974932670593,0.02207610197365284,0.049316775053739548,-0.015461069531738758,0.0072634825482964516,-0.041865836828947067,-0.0068650548346340656,0.013807328417897224,-0.0037389222998172045,-0.044770490378141403,0.0068881921470165253,0.021339572966098785,0.0051484955474734306,-0.02549155056476593,0.060375645756721497,0.020760152488946915,0.039136577397584915,0.0062082237564027309,-0.051224749535322189,-0.051565311849117279,0.013782820664346218,-0.029110178351402283,0.015260511077940464,0.031988389790058136,0.040680401027202606,0.030093535780906677,-0.036548495292663574,0.034533791244029999,0.04699389636516571,-0.017273101955652237,0.021868310868740082,-0.0054267714731395245,-0.046487264335155487,-0.011321754194796085,0.02054104395210743,0.027594607323408127,-0.023689284920692444,0.012154912576079369,-0.0041120485402643681,-0.0091637428849935532,0.0031583709642291069,0.010620936751365662,-0.0050705983303487301,-0.022322854027152061,-0.022065106779336929,0.023746704682707787,-0.014495838433504105,-0.012354140169918537,-0.046505138278007507,0.021199852228164673,-0.003941674716770649,-0.027136176824569702,0.0041805468499660492,-0.04115397110581398,0.037554427981376648,0.0012104058405384421,0.032513342797756195,0.074414238333702087,-0.027278497815132141,-0.010119883343577385,0.022009281441569328,0.029538961127400398,0.01640663854777813,-0.06663978099822998,-0.032937303185462952,0.026348160579800606,-0.019124025478959084,0.034068647772073746,-0.061192914843559265,0.015296517871320248,0.03328096866607666,0.019865510985255241,0.048565272241830826,-0.050992920994758606,0.0074040954932570457,0.0087697599083185196,0.0038647772744297981,-0.015297834761440754,-0.023430531844496727,-0.032400269061326981,0.05222335085272789,-0.0063633900135755539,-0.035167720168828964,0.020548164844512939,-0.017314910888671875,0.072730444371700287,-0.020061800256371498,0.010379401966929436,0.0026712098624557257,0.024437058717012405,0.055597830563783646,0.028081094846129417,0.018453335389494896,-0.059673316776752472,0.016971325501799583,0.04643569141626358,-0.010773518122732639,-0.0074593145400285721,-0.036781959235668182,-0.028073292225599289,-0.021165020763874054,-0.053516577929258347,0.01389397494494915,0.053105935454368591,-0.012174703180789948,0.011300351470708847,0.0018182353815063834,0.032010648399591446,-0.014791670255362988,0.0036643785424530506,-0.0035601223353296518,0.00169432966504246,-0.0061322730034589767,-0.019261570647358894,-0.052761517465114594,0.0043331733904778957,-0.023405889049172401,-0.0013054362498223782,-0.038325980305671692,0.02234351821243763,-0.020316729322075844,-0.010952194221317768,-0.0026647683698683977,-0.017443280667066574,0.028862243518233299,-0.021959662437438965,-0.046642553061246872,0.0042391922324895859,-0.051883362233638763,0.011691072024405003,-0.038915291428565979,0.024683644995093346,-0.00091420498210936785,-0.0095504401251673698,-0.071193724870681763,0.013452977873384953,0.0035779622849076986,0.03549451008439064,0.018556013703346252,-0.027256513014435768,-0.024853691458702087,-0.013916970230638981,-0.012280788272619247,0.0021221304778009653,0.0022675865329802036,0.089058496057987213,0.0024201399646699429,-0.0048117740079760551,-0.0057366518303751945,0.025161929428577423,0.048330999910831451,0.015337476506829262,0.032063588500022888,-0.017362365499138832,0.0099482433870434761,0.05601823702454567,0.033268816769123077,-0.035882279276847839,-0.0047324257902801037,-0.03033473901450634,0.017119180411100388,-0.031441368162631989,-0.043387580662965775,-0.0052176737226545811,-0.019093003123998642,0.0083253029733896255,0.002182497177273035,-0.015315691940486431,-0.0050778258591890335,0.032804384827613831,-0.048603914678096771,0.018079707399010658,0.046641957014799118,0.0064123077318072319,-0.066496215760707855,-0.038945909589529037,0.0033663073554635048,0.0073735103942453861,-0.048868976533412933,-0.055136624723672867,-0.018187398090958595,-0.013666290789842606,-0.0086443210020661354,-0.0093931518495082855,0.0065682181157171726,-0.007914089597761631,-0.065493114292621613,-0.064873777329921722,0.023716287687420845,-0.011872446164488792,0.031232437118887901,0.037807673215866089,0.0015283311950042844,-0.022662173956632614,0.016465635970234871,-0.01046160701662302,0.042473223060369492,-0.0052532297559082508,-0.0066502504050731659,-0.014517301693558693,-0.021044084802269936,-0.030467977747321129,-0.071140803396701813,-0.027173178270459175,0.059272579848766327,-0.0013943332014605403,-0.020940547809004784,-0.004419941920787096,0.0063467551954090595,0.038910184055566788,0.052343174815177917,-0.028728863224387169,0.011732944287359715,0.021289363503456116,-0.055798493325710297,-0.038842339068651199,0.044947247952222824,0.02441762201488018,-0.0086776651442050934,-0.013388664461672306,-0.018683692440390587,-0.035569734871387482,0.034994121640920639,0.060199528932571411,0.0086821494624018669,-0.017897795885801315,-0.0097756162285804749,-0.0095259156078100204,-0.00026338250609114766,-0.035030871629714966,-0.036315254867076874,-0.0073267160914838314,0.017055833712220192,0.051266193389892578,0.026408467441797256,0.014815188944339752,0.0072418665513396263,-0.024581056088209152,0.010313536040484905,0.047205414623022079,-0.036138296127319336,-0.014613096602261066,0.0054184058681130409,0.015539579093456268,-0.066070429980754852,0.0057611675001680851,-0.09241090714931488,0.0052681951783597469,-0.0013419043971225619,-0.025752810761332512,0.017354480922222137,0.017572777345776558,-0.023573664948344231,-0.030024390667676926,-0.025660784915089607,-0.0097606591880321503,-0.015134649351239204,-0.015287980437278748,-0.037448316812515259,0.015478561632335186,-0.0031650506425648928,-0.030225794762372971,-0.052669156342744827,0.060206335037946701,0.002581301610916853,0.020695371553301811,0.080319158732891083,0.0037524488288909197,0.025013512000441551,0.047787081450223923,0.0025819775182753801,0.0090151699259877205,-0.020570492371916771,0.0095280185341835022,-0.020616816356778145,0.0091758361086249352,-0.051330067217350006,-0.07755511999130249,-0.027056649327278137,0.0050598271191120148,0.0080269621685147285,0.047498438507318497,-0.0065127392299473286,-0.018920017406344414,0.075119540095329285,0.027064692229032516,0.0098685622215270996,0.023606708273291588,-0.03257322683930397,0.053058046847581863,-0.027920423075556755,0.00035854836460202932,0.052203807979822159,-0.031770080327987671,0.031482268124818802,-0.014773235656321049,0.024185489863157272,-0.056658957153558731,0.0070734298788011074,-0.042002968490123749,0.0026305904611945152,-0.01066125649958849,-0.02896357886493206,-0.0097189359366893768,0.01806289330124855,0.011441475711762905,-0.021583143621683121,-0.0062351059168577194,-0.031566750258207321,-0.026066306978464127,0.020607396960258484,-0.0099304849281907082,0.0088631818071007729,-0.017030349001288414,0.008817954920232296,0.00080581952352076769,0.021539673209190369,0.080019652843475342,-0.044647373259067535,0.050556439906358719,0.0036073822993785143,0.014935029670596123,0.034807775169610977,-0.049796439707279205,0.026013633236289024,0.032238207757472992,0.043684955686330795,-0.015294336713850498,0.024539763107895851,-0.01375786866992712,0.033565491437911987,0.0022785014007240534,-0.040164928883314133,0.012193880043923855,0.027826111763715744,0.002673230366781354,-0.023367861285805702,-0.02036256343126297,0.042004961520433426,0.0038357332814484835,0.049248736351728439,-0.0051882411353290081,-0.06807437539100647,-0.027521789073944092,-0.0029114158824086189,-0.03517884761095047,-0.038478467613458633,0.037279251962900162,0.0086821820586919785,-0.024448931217193604,-0.019540539011359215,0.0057122469879686832,-0.0076289833523333073,-0.021654065698385239,-0.027560601010918617,-0.023471575230360031,0.024011405184864998,0.013374196365475655,-0.04415426030755043,-0.011496739462018013,0.035581722855567932,0.0057859714142978191,-0.0062058707699179649,-0.011432294733822346,-0.038295373320579529,-0.047548238188028336,-0.019009165465831757,0.015005804598331451,0.041029844433069229,-0.010155393742024899,0.012707005254924297,-0.010240664705634117,-0.016737030819058418,0.0079981070011854172,0.0082807037979364395,-0.029436081647872925,-0.027589751407504082,-0.02592683769762516,-0.0016054768348112702,-0.071674525737762451,0.028023211285471916,-0.0064964382909238338,0.018062267452478409,0.011560906656086445,-0.026482133194804192,-0.023755049332976341,0.0023532463237643242,-0.024099046364426613,0.013330161571502686,0.024465415626764297,-0.020662358030676842,0.026347488164901733,-0.022277431562542915,0.033949647098779678,-0.013070070184767246,0.045655395835638046,-0.040297545492649078,0.018975522369146347,0.020187631249427795,0.027368053793907166,0.038053307682275772,-0.052168838679790497,0.00088151468662545085,0.034813214093446732,-0.042671453207731247,-0.019810650497674942,-0.0063579748384654522,0.026508614420890808,-0.020700328052043915,-0.053222265094518661,0.029718711972236633,-0.0024248678237199783,-0.021839315071702003,-0.010701723396778107,0.012801217846572399,0.018886787816882133,0.016468903049826622,-0.0016970542492344975,-0.0043472792021930218,-0.025320351123809814,0.0058209355920553207,-0.081084705889225006,0.068614482879638672,0.0021080507431179285,-0.010501587763428688,-0.049483645707368851,0.00052624341333284974,-0.029110999777913094,0.080577857792377472,-0.016771377995610237,-0.021137911826372147,-0.041810102760791779,-0.02486821636557579,0.03684312105178833,0.016371838748455048,0.034965973347425461,0.008225511759519577,0.0023998210672289133,0.013391865417361259,0.034024644643068314,0.034535214304924011,0.016759524121880531,0.025518758222460747,0.0045380126684904099,0.02878396213054657,-0.024739610031247139,-0.0037357143592089415,-0.0023904652334749699,0.043193124234676361,0.043461542576551437,0.000040283695852849633,-0.025617847219109535,0.0041299057193100452,-0.060699097812175751,0.037842869758605957,-0.015292679890990257,-0.011860270984470844,0.088123701512813568,0.016280403360724449,0.052728578448295593,0.036744315177202225,-0.021208690479397774,-0.056602239608764648,-0.001976468600332737,-0.035609174519777298,-0.051893983036279678,0.013002173975110054,-0.0051866983994841576,-0.010878279805183411,0.0070363646373152733,-0.044179808348417282,-0.06872907280921936,0.0020061344839632511,-0.045914854854345322,0.043180864304304123,-0.0061019081622362137,0.031903322786092758,-0.021610813215374947,-0.0081337727606296539,0.023984275758266449,0.0088662989437580109,-0.023490181192755699,-0.0028303894214332104,-0.054698728024959564,0.014958614483475685,-0.0056156991049647331,-0.022438956424593925,-0.025739343836903572,-0.031840398907661438,0.00077713001519441605,-0.0057523529976606369,-0.042405609041452408,0.016883037984371185,0.018560146912932396,0.04644383117556572,-0.03052462637424469,-0.016234058886766434,0.017291849479079247,-0.0042335544712841511,0.042128607630729675,-0.040222696959972382,0.023533053696155548,0.0048290379345417023,-0.0097476188093423843,-0.0055055799894034863,0.028594024479389191,0.00072855543112382293,0.028764242306351662,0.050942540168762207,0.022638086229562759,0.021435284987092018,-0.0005695940344594419,0.016081757843494415,-0.014481873251497746,0.036004688590764999,-0.034099552780389786,0.0030469968914985657,0.027942223474383354,0.027207890525460243,0.0095733422785997391,-0.038510773330926895,-0.013104896061122417,-0.02916327491402626,-0.017403321340680122,-0.013296604156494141,-0.016401899978518486,0.052185434848070145,0.010420698672533035,0.030923010781407356,-0.0300751943141222,-0.038953818380832672,-0.035351544618606567,-0.020032968372106552,-0.022082541137933731,-0.014077621512115002,0.00022399239242076874,0.047364182770252228,0.032103966921567917,-0.036455824971199036,0.0085648326203227043,0.030359860509634018,0.052310824394226074,-0.0084916884079575539,0.026466822251677513,0.015032453462481499,-0.029854318127036095,-0.0065254089422523975,0.023966774344444275,0.004576604813337326,-0.0033361110836267471,0.01672772690653801,-0.014797544106841087,0.021931447088718414,-0.0052121975459158421,0.0046095335856080055,-0.01438327319920063,-0.010917562991380692,0.027919493615627289,-0.023236611858010292,-0.062245573848485947,-0.04013526439666748,0.041906032711267471,0.041407279670238495,-0.023554027080535889,0.021511130034923553,-0.043404370546340942,-0.0026499417144805193,-0.041216202080249786,-0.029359214007854462,0.037551391869783401,-0.00059818639419972897,-0.01370974350720644,0.0058054132387042046,0.057808864861726761,0.045188590884208679,-0.060475118458271027,-0.027690930292010307,-0.0035100486129522324,0.02102736197412014,0.013938862830400467,-0.042450759559869766,-0.019114959985017776,0.078232012689113617,-0.031545501202344894,0.036313947290182114,-0.038652390241622925,0.023972123861312866,0.012194412760436535,-0.015808112919330597,-0.021169558167457581,-0.015675438567996025,-0.016651056706905365,0.02302253432571888,-0.014751746319234371,-0.015032097697257996,0.0012104274937883019,0.047810785472393036,0.057774543762207031,-0.021574970334768295,0.025868307799100876,0.025900697335600853,-0.0185523871332407,-0.02425694465637207,0.02797565795481205,-0.0047021601349115372,-0.021062122657895088,-0.028223948553204536,0.050444405525922775,-0.034294776618480682,0.0066602947190403938,-0.025776168331503868,-0.046253081411123276,0.00043972829007543623,-0.012406874448060989,-0.037625629454851151,0.034667607396841049,-0.045398928225040436,0.050638966262340546,-0.027737339958548546,0.010657693259418011,-0.04967210441827774,0.020398490130901337,-0.013149539940059185,-0.0039252648130059242,-0.0014901369577273726,-0.0073957052081823349,0.034007392823696136,-0.026224648579955101,-0.040920611470937729,-0.012686158530414104,-0.036390345543622971,0.050277341157197952,0.022918028756976128,-0.0033539100550115108,0.0012007275363430381,-0.0040165791288018227,0.033601962029933929,0.0090254545211791992,-0.048045199364423752,-0.039490442723035812,-0.033135071396827698,0.00043357588583603501,0.017947107553482056,0.058827966451644897,-0.045226603746414185,-0.040601626038551331,-0.053124032914638519,-0.054107092320919037,0.024035947397351265,0.024969631806015968,-0.00035981391556560993,-0.023837065324187279,0.042570393532514572,-0.0049582221545279026,0.0099606448784470558,0.056517470628023148,0.02708711288869381,0.06416059285402298,0.038509547710418701,0.00062521605286747217,0.011677233502268791,-0.0031348331831395626,-0.013381070457398891,-0.040585294365882874,0.046590782701969147,0.030826400965452194,0.05109110102057457,-0.014557457529008389,-0.016682004556059837,-0.019985532388091087,-0.036794010549783707,0.049517348408699036,-0.0098937861621379852,-0.026719080284237862,-0.0052037942223250866,-0.023969285190105438,-0.029247002676129341,-0.056310702115297318,-0.050204575061798096,0.066085606813430786,-0.064198978245258331,0.016437070444226265,-0.0088326381519436836,-0.0073702842928469181,0.059009768068790436,-0.015872512012720108,-0.07865653932094574,-0.027243828400969505,-0.034644108265638351,0.025566987693309784,-0.040692847222089767,-0.014113320037722588,-0.045657414942979813,-0.051010046154260635,-0.036315567791461945,0.014999063685536385,-0.050846464931964874,-0.044098678976297379,-0.0070443986915051937,-0.0048666833899915218,-0.013374393805861473,-0.0053807883523404598,-0.015955813229084015,-0.0174064040184021,-0.015998169779777527,-0.0039422083646059036,-0.018468178808689117],"face_num":1,"landmark_num":105,"pose":[22.396007537841797,-4.4076366424560547,-8.5078458786010742],"face_prob":[1.0],"landmark":[235.93852233886719,181.224853515625,294.37744140625,178.40582275390625,264.34829711914062,168.43838500976562,265.21820068359375,181.068603515625,244.18270874023438,174.37684631347656,253.68893432617188,169.44540405273438,274.91009521484375,170.20683288574219,285.31637573242188,172.76420593261719,245.7025146484375,181.55178833007812,255.45036315917969,180.93173217773438,274.9759521484375,180.59864807128906,284.71737670898438,179.86380004882812,318.85360717773438,174.85110473632812,348.05731201171875,165.13105773925781,331.5556640625,160.9132080078125,333.79730224609375,171.04098510742188,321.5040283203125,168.97720336914062,326.29443359375,164.64872741699219,337.69158935546875,158.89509582519531,344.01312255859375,160.14520263671875,323.97601318359375,174.20709228515625,328.93255615234375,172.76882934570312,338.48550415039062,168.87889099121094,343.42547607421875,167.390625,255.98895263671875,197.39018249511719,284.51080322265625,196.33258056640625,259.40728759765625,195.14834594726562,263.135498046875,193.47883605957031,266.98919677734375,192.1165771484375,270.88916015625,190.89151000976562,274.89813232421875,190.09413146972656,278.94927978515625,190.60324096679688,282.3414306640625,192.8724365234375,259.31668090820312,199.40296936035156,262.933837890625,200.82931518554688,266.71490478515625,201.73101806640625,270.58990478515625,202.03324890136719,274.47015380859375,201.78759765625,278.2349853515625,200.81881713867188,281.65960693359375,198.9774169921875,324.36822509765625,192.35784912109375,346.50103759765625,183.86358642578125,325.71780395507812,189.13784790039062,327.86288452148438,186.38262939453125,330.47708129882812,184.0677490234375,333.50164794921875,182.32244873046875,336.78564453125,181.14013671875,340.26416015625,180.99319458007812,343.625,181.89608764648438,327.57489013671875,193.19772338867188,330.883544921875,193.38864135742188,334.1925048828125,193.19383239746094,337.42742919921875,192.47308349609375,340.51608276367188,191.27230834960938,343.3675537109375,189.6021728515625,345.39093017578125,186.98699951171875,307.93850708007812,195.653564453125,322.97787475585938,229.98866271972656,315.42767333984375,212.81187438964844,318.6104736328125,240.16804504394531,296.4090576171875,242.57423400878906,333.49383544921875,235.08760070800781,289.90362548828125,273.78512573242188,336.55206298828125,266.83981323242188,297.21453857421875,272.32388305664062,330.28485107421875,266.93109130859375,316.1566162109375,258.78811645507812,310.74346923828125,258.21832275390625,321.9896240234375,256.18374633789062,299.77841186523438,265.2615966796875,330.18899536132812,260.27825927734375,294.57672119140625,269.21646118164062,304.99990844726562,261.33135986328125,326.265625,257.87847900390625,333.75286865234375,263.18707275390625,319.6361083984375,280.97247314453125,304.2489013671875,279.99725341796875,329.53201293945312,275.79522705078125,297.0303955078125,276.99725341796875,311.863525390625,281.74249267578125,325.07830810546875,279.33895874023438,333.28125,271.50576782226562,316.33270263671875,266.66729736328125,317.069580078125,270.3067626953125,306.55950927734375,268.7802734375,307.10260009765625,271.0684814453125,323.3345947265625,265.84170532226562,323.5369873046875,268.10223388671875,301.7786865234375,270.26226806640625,302.1114501953125,271.33126831054688,311.3896484375,267.45767211914062,312.08770751953125,270.70928955078125,319.82177734375,266.12884521484375,320.22772216796875,268.97854614257812,326.84783935546875,266.12237548828125,326.92303466796875,267.59002685546875,191.38597106933594,202.93789672851562,353.01336669921875,183.304443359375,324.28335571289062,316.0045166015625,229.84408569335938,290.48208618164062,354.11669921875,249.325439453125,204.9068603515625,247.78366088867188,356.8758544921875,215.63363647460938,277.8021240234375,314.37930297851562,345.1080322265625,284.13601684570312],"request_id":"6F6EA713-4FD6-4346-A14B-B9453894C501","errno":0,"age":[25],"glass":[0],"iris":[275.29409790039062,195.13554382324219,5.8044281005859375,334.48928833007812,187.0887451171875,5.8044281005859375],"gender":[0],"face_rect":[208,103,152,218],"dense_fea_len":1024},"RequestId":"6F6EA713-4FD6-4346-A14B-B9453894C501","Success":true}
------------------------------------------
{"Data":{"rectA":[242,45,122,144],"err_msg":"","thresholds":[60.03,67.05,75.45],"rectB":[208,103,152,218],"request_id":"9C2782E4-58DD-4FF3-B0A7-E656506CBF85","errno":0,"confidence":0.5836532},"RequestId":"9C2782E4-58DD-4FF3-B0A7-E656506CBF85","Success":true}
------------------------------------------
1:N function Demo
{"Data":"ok","RequestId":"1292BF49-25C0-4869-A7A4-0621B2258576","Success":true}{"Data":"ok","RequestId":"F303379F-9C1D-426E-8389-B7C576B69711","Success":true}
------------------------------------------
{"Data":{"mark":0,"list":[{"person":"LiuYifei","image":"photo1"},{"person":"LiuYifei","image":"photo2"}]},"RequestId":"265C914A-5425-4192-B4C1-52D97BFF0A7A","Success":true}
------------------------------------------
{"Data":["default","default1","defaultPython","defaultPythonDemo1","defaultPythonDemo2","defaultjs","defaultjsdemo","defaultPHPDemo","defaultPHPDemo1"],"RequestId":"5ECD88FD-CF7F-4F6F-9246-C49E211C90DA","Success":true}
------------------------------------------
{"Data":[{"person":"LiuYifei","score":0.65704226,"image":"photo2","rect":[146,131,132,179]}],"RequestId":"BF46085E-CE9B-4E60-A3BD-6A0BFABCBF85","Success":true}
------------------------------------------
{"Data":"ok","RequestId":"DDB52FFD-D4EF-4EFD-9F98-08D3D2B7B4D5","Success":true}
------------------------------------------
{"Data":{"mark":0,"list":[{"person":"LiuYifei","image":"photo2"}]},"RequestId":"214AD51D-87B1-4DB4-BF76-ED0756D477ED","Success":true}

4、如果有使用本地图片的需求,可以提供请求中的:ImageUrl 为 Content,本地图片的处理可以参考:阿里云人脸识别PHP调用示例参考 本地图片处理方法。

参考链接

人脸查找1:N API调用说明

阿里云人脸识别PHP调用示例参考

版权声明:本文中所有内容均属于阿里云开发者社区所有,任何媒体、网站或个人未经阿里云开发者社区协议授权不得转载、链接、转贴或以其他方式复制发布/发表。申请授权请邮件developerteam@list.alibaba-inc.com,已获得阿里云开发者社区协议授权的媒体、网站,在转载使用时必须注明"稿件来源:阿里云开发者社区,原文作者姓名",违者本社区将依法追究责任。 如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:developer2020@service.aliyun.com 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
上一篇:阿里云新版人脸识别 NODEJS 使用示例教程 下一篇:阿里云新版人脸识别基于JAVA签名校验使用示例教程

集结各类场景实战经验,助你开发运维畅行无忧

其他文章