我刚刚设置了一个带有http端点的基本google云函数。我想要将一个图像传递到这个端点,并将其一直发送到vision api (已经设置),然后将来自vision api的响应发送回响应。
所以基本上:
image in POST request -> cloud-function -> vision api ->|
response of vision api <- cloud function <- vision api <-|这是将图像发送到vision 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请求中的图像并将其发送到vision API?
谢谢!
发布于 2018-05-18 19:16:47
我会将图片放入Google云存储桶中,将对象设为public,然后只将桶的名称/url发送给vision API。
https://stackoverflow.com/questions/50393277
复制相似问题