{ "time_used": 2299, "image_id": "lHjvzhnGndA/zZja3ho2fA==", "skeletons": [{ "body_rectangle": { "width": 781, "top": 315, "height": 910, "left": 134 }, "landmark": { "left_buttocks": { "y": 901, "x": 452, "score": 0.7299447 }, "head": { "y": 9, "x": 305, "score": 0.5368539 }, "neck": { "y": 673, "x": 378, "score": 0.6446256 }, "left_shoulder": { "y": 692, "x": 769, "score": 0.7006054 }, "left_hand": { "y": 597, "x": 769, "score": 0.41823307 }, "left_knee": { "y": 901, "x": 329, "score": 0.6185796 }, "right_elbow": { "y": 901, "x": 12, "score": 0.4332367 }, "right_shoulder": { "y": 635, "x": 12, "score": 0.724305 }, "right_hand": { "y": 901, "x": 232, "score": 0.56872773 }, "left_foot": { "y": 901, "x": 452, "score": 0.3753785 }, "left_elbow": { "y": 901, "x": 769, "score": 0.51084995 }, "right_buttocks": { "y": 901, "x": 134, "score": 0.5565492 }, "right_knee": { "y": 901, "x": 85, "score": 0.47690523 }, "right_foot": { "y": 901, "x": 452, "score": 0.52765757 } } }, { "body_rectangle": { "width": 559, "top": 533, "height": 740, "left": 394 }, "landmark": { "left_buttocks": { "y": 732, "x": 114, "score": 0.8086717 }, "head": { "y": 270, "x": 464, "score": 0.4876535 }, "neck": { "y": 270, "x": 79, "score": 0.5550944 }, "left_shoulder": { "y": 378, "x": 359, "score": 0.64766926 }, "left_hand": { "y": 362, "x": 481, "score": 0.6320832 }, "left_knee": { "y": 563, "x": 271, "score": 0.49012265 }, "right_elbow": { "y": 378, "x": 551, "score": 0.6178683 }, "right_shoulder": { "y": 347, "x": 324, "score": 0.5143001 }, "right_hand": { "y": 378, "x": 551, "score": 0.6799432 }, "left_foot": { "y": 732, "x": 9, "score": 0.4409459 }, "left_elbow": { "y": 362, "x": 499, "score": 0.56940734 }, "right_buttocks": { "y": 732, "x": 201, "score": 0.6996023 }, "right_knee": { "y": 424, "x": 551, "score": 0.48145446 }, "right_foot": { "y": 732, "x": 9, "score": 0.43120167 } } }], "request_id": "1533886107,224911b6-e136-42bd-aebb-e1aec327e018" }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/11/02 21:53 */ //---------------------------------- // 人体关键点检测 调用类 //---------------------------------- class freeApi { private $apiKey = false; private $apiSecret = false; private $apiUrl = 'https://api-cn.faceplusplus.com/humanbodypp/v1/skeleton'; public function __construct($apikey,$apiSecret){ $this->apiKey = $apikey; $this->apiSecret = $apiSecret; } /** * 将JSON内容转为数据,并返回 * @param string $content [内容] * @return array */ public function returnArray($content){ return json_decode($content,true); } /** * 获取结果 * @return array */ public function getResult(){ $params = [ "api_key" => $this->apiKey, "api_secret" => $this->apiSecret, "image_url" => "", ]; $params = http_build_query($params); return $this->returnArray($this->freeApiCurl($this->apiUrl,$params,1)); } /** * 请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ipost [是否采用POST形式] * @return string */ public function freeApiCurl($url,$params=false,$ispost=0){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST , false ); curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER , false ); curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 60); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); curl_setopt( $ch , CURLOPT_POSTFIELDS , $params ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); if ($response === FALSE) { return false; } curl_close( $ch ); return $response; } }