PHP人脸检测:cloudinary API面数

时间:2016-07-03 13:49:00

标签: php api face-detection cloudinary

我以这种方式使用cloudinary人脸检测API:

require 'cloudinary/Cloudinary.php';
require 'cloudinary/Uploader.php';
require 'cloudinary/Api.php';

\Cloudinary::config(array(
    "cloud_name" => "xxxxxxxxxxxx",
    "api_key" => "9999999999999",
    "api_secret" => "xxxxxxxxxxxxx"
));

$img = 'guy.jpg';
$imgid = time() . 'guy';

\Cloudinary\Uploader::upload($img, array("public_id" => $imgid));

$url = 'http://res.cloudinary.com/xxxxxx/image/upload/c_fill,g_face,h_500,w_375/' . $imgid . '.jpg';
file_put_contents('cropped' . $img, file_get_contents($url));

但我还需要的是:

\Cloudinary\Uploader::upload($img, array("public_id" => $imgid));

// what I need >>>
if('face_count != 1')
{
    exit;
}
// <<< what I need

$url = 'http://res.cloudinary.com/xxxxxx/image/upload/c_fill,g_face,h_500,w_375/' . $imgid . '.jpg';
file_put_contents('cropped' . $img, file_get_contents($url));

我不明白如何使用doc中的face_count:http://cloudinary.com/documentation/image_transformations#specifying_conditions

1 个答案:

答案 0 :(得分:0)

感谢Nadav的回答,我这样解决了:

<sup> x </sup>