【发布时间】:2019-05-24 02:55:28
【问题描述】:
我尝试了 Google Vision API (PHP) 示例
# includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# imports the Google Cloud client library
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
# instantiates a client
$imageAnnotator = new ImageAnnotatorClient();
# the name of the image file to annotate
$fileName = 'test/data/wakeupcat.jpg';
# prepare the image to be annotated
$image = file_get_contents($fileName);
# performs label detection on the image file
$response = $imageAnnotator->labelDetection($image);
$labels = $response->getLabelAnnotations();
if ($labels) {
echo("Labels:" . PHP_EOL);
foreach ($labels as $label) {
echo($label->getDescription() . PHP_EOL);
}
} else {
echo('No label found' . PHP_EOL);
}
我可以得到图像中物体的标签,它很棒,但标签是英文。我可以配置 API 返回其他语言或多语言吗?
P/S: 对不起我的英语不好:(
【问题讨论】:
标签: php google-api google-cloud-vision