本文介绍了带有Node.js的Google Vision API文本检测设置了语言提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将@google-cloud/vision
与Node.js一起使用
I'm using @google-cloud/vision
with Node.js
我使用以下示例代码
async function quickstart() {
try {
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
// Performs label detection on the image file
const [result] = await client.textDetection('./test.jpg');
const texts = result.textAnnotations;
console.log('Text:');
texts.forEach((text: string) => console.log(text));
} catch (err) {
console.log(err);
}
}
这当前正在工作,并且返回英文文本和数字.我在图像中使用了Vision API的实验语言.如何将语言提示设置为node.js API中指定的文档?
This is currently working working and return english texts and numbers. I have texts in image which Vision API's Experimental languages. How can I set the language hint as document specified in node.js API?
https://cloud.google.com/vision/docs/ocr
推荐答案
您可以使用batchAnnotateImages方法.例如:类似
You can use the batchAnnotateImages method. Eg: something like:
const request = {
features: [{type: 'TEXT_DETECTION'}],
imageContext: {
languageHints: ["en-t-i0-handwrit"]
},
<other parts of your request>
};
const [response] = await imageAnnotatorClient.batchAnnotateImages({
requests: [request],
});
这篇关于带有Node.js的Google Vision API文本检测设置了语言提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!