我正在使用Google Cloud Vision API进行文档文本检测。我正在使用的功能是DOCUMENT_TEXT_DETECTION,我试图告诉Google Vision我正在使用哪种语言,但似乎无法正常工作。
我应该从全日文输出的响应中检索结果,但是它一直给我提供繁体中文结果。
我想知道的是,我可以使用DOCUMENT_TEXT_DETECTION功能告诉Cloud Vision API我正在阅读的文档的语言。
我尝试了language_hints参数,但没有任何改变。
我正在使用的代码如下。
private function getSingleAnnotationResponse(string $imageFilePath, array $featureTypeList = [Type::DOCUMENT_TEXT_DETECTION])
{
$imageAnnotator = new ImageAnnotatorClient();
$fileContent = file_get_contents($imageFilePath);
try {
$response = $imageAnnotator->annotateImage($fileContent, $this->createFeatureList($featureTypeList), [
new ImageContext([
'language_hints' => ['ja-t-i0-handwrit'],
])
]);
} catch (ApiException $e) {
\Log::warning($e->getMessage());
$response = null;
}
$imageAnnotator->close();
return $response;
}