【发布时间】:2018-07-14 06:46:41
【问题描述】:
我刚刚设置了一个带有 http 端点的基本谷歌云功能。 我想将图像传递到此端点并将其一直发送到视觉 api(已设置),然后将视觉 api 的响应发送回响应。
基本上就是这样:
image in POST request -> cloud-function -> vision api ->|
response of vision api <- cloud function <- vision api <-|
这是将图像发送到视觉 api 的基本代码:
const vision = require("@google-cloud/vision");
// Creates a client
const client = new vision.ImageAnnotatorClient();
const timeStart = new Date();
// Performs text detection on the local file
client
.textDetection(file)
.then(results => {
const detections = results[0].textAnnotations;
console.log("Text:");
detections.forEach(text => console.log(text));
const timeEnd = new Date();
console.log(timeEnd - timeStart);
})
.catch(err => {
console.error("ERROR:", err);
});
如何处理 POST 请求中的图像并将其发送到视觉 API?
谢谢!
【问题讨论】:
-
当然可以。但没有发现什么好东西
标签: javascript node.js google-cloud-platform