Google Cloud Vision可以返回更多标签语言吗?

时间:2019-05-24 02:55:28

标签: php google-api google-cloud-vision

我尝试了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:对不起,我的英语不好:(

1 个答案:

答案 0 :(得分:0)

作为一种解决方法,您可以尝试使用其他 API 来翻译它,例如: https://github.com/googleapis/google-cloud-php-translate

亲切的问候