我正在尝试制作面部识别系统,我使用KeyLemon API,我在EasyPHP中复制了文件(最后一个版本,因此PHP 5),当我想使用的功能时,我有很多错误API。
//ssl certificate
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, Server_Connection::SSL_VERIFYPEER);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, Server_Connection::SSL_VERIFYHOST);
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/CA/KL_GlobalSignOrganizationValidationCA-G2.crt');
我也尝试curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2, Server_Connection::SSL_VERIFYHOST); but i get the still error : Warning: curl_setopt() expects exactly 3 parameters, 4 given
在index.php中:
Notice: Undefined property: stdClass::$gender in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\src\index.php on line 35
Notice: Undefined property: stdClass::$age in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\src\index.php on line 36
API必须工作,我没有触及anuthing,我想这是因为PHP的版本。
的index.php
try{
//images can be given as an url array or data directly. If sending a path, add the prefix @
$images_url = array('http://www.keylemon.com/images/saas/group.jpg');
$images_data = array(file_get_contents(__DIR__.'/penelope.jpg'), '@'.__DIR__.'/alba.jpg');
//detect face(s) in the image and request gender+age (properties)
$properties = true;
$res_detect = $kl_api->detect_faces($images_url, $images_data, $properties);
//check if some errors
if($res_detect->errors){
foreach($res_detect->errors as $error){
print $error->error_id.':'.$error->message;
}
}
//print faces detected
if($res_detect->faces){
foreach($res_detect->faces as $face){
print $face->face_id.': position:'.$face->x.','.$face->y.', size:'.$face->w.'x'.$face->h.'<br/>';
print 'Gender : '.$face->gender;
print 'Age : '.$face->age;
}
}
}
catch (KL_Exception $e){
print $e->getMessage();
}
在页面中:
Warning: curl_setopt() expects exactly 3 parameters, 4 given in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\src\server_connection.php on line 188
711be4c4-4741-4756-866e-477045c33847: position:268,288, size:300x300
Gender : femaleAge : 18ea840197-4c6d-4c4a-883b-fd18d69a6aba: position:242,882, size:19x19
Notice: Undefined property: stdClass::$gender in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\src\index.php on line 35
Gender :
Notice: Undefined property: stdClass::$age in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\src\index.php on line 36
Age : f0b7dcef-2918-4b20-a08f-2b5402810baf: position:63,73, size:100x100
Gender : femaleAge : 1940cc8492-ab6d-488d-a06e-081f1cc22c62: position:485,131, size:136x136
Gender : maleAge : 186d32a3a9-f822-4ec2-a372-c1cda4c6ccae: position:144,265, size:134x134
Gender : femaleAge : 15b66a6e1a-5c3e-4270-90e7-d92ca951b0f8: position:715,234, size:125x125
Gender : femaleAge : 192897a4f1-5406-4d85-bdda-008251a137a0: position:840,168, size:117x117
Gender : maleAge : 28
答案 0 :(得分:0)
没有错误,有通知和警告。
例如,在index.php
中,通知表示您正在尝试访问未在对象($face->gender
和$face->age
中定义的属性。您应该更仔细地查看API文档。
出现警告是因为您将4个参数传递给curl_setopt
函数,该函数需要正好3个参数。