【问题标题】:Cannot fetch image OCR computer vision API Cognitive server nodejs无法获取图像 OCR 计算机视觉 API 认知服务器 nodejs
【发布时间】:2017-01-08 10:19:06
【问题描述】:

我正在使用计算机视觉 Api 并尝试使用节点 js 将图像从 url 发布到 ocr 微软认知服务,但我明白了

{"code":"InvalidImageUrl","requestId":"a4c68f18-37c1-484d-a044-2f89df963915","message":"Can't fetch the image."}

这是我的获取和发布代码

http.get(url.parse(imageUrl), function (res) {
    res.on('data',function (body) {
        console.log('data from get '+body);
      })    
    res.on('end', function () {


        request.post({
            headers: {                    
                'Ocp-Apim-Subscription-Key': proccess.env.SUBSKEY
            },
            url: 'http://api.projectoxford.ai/vision/v1.0/ocr?language=unk&detectOrientation=true',
            encoding: 'binary',
            formdata:{
                file:res
            }
        }, function (error, response, body) {
            if(error)
            {
                console.log(error);
            }
            console.log('data from post '+body);
        });
    });
});

我也在使用 botbuilder

【问题讨论】:

    标签: node.js microsoft-cognitive botbuilder


    【解决方案1】:

    嗨,如果有人遇到同样的错误,我会使用请求管道而不是 http get 并将发布选项移动到 var 来解决这个问题

    request.get(imageUrl).pipe(request.post(postOptions,function(error,response,body) {  
    
               /*Do some cool stuff
                */
    }
    ));
    

    【讨论】:

      猜你喜欢
      • 2021-10-26
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      相关资源
      最近更新 更多