【问题标题】:What is the best way to create a link from an image uploaded by the user?从用户上传的图像创建链接的最佳方法是什么?
【发布时间】:2021-01-04 21:22:02
【问题描述】:

我正在尝试创建一个使用 IBM Watson Visual Recognition 进行垃圾分类的应用程序。 Watson 在后端(node js)运行,我想在Vue 中开发应用程序。

Watson 需要一个图片链接,我正在考虑使用 firebase 在用户上传图片时创建链接。

我的问题是:“考虑到图像及其结果对用户来说应该是唯一的并且不必坚持下去,有没有更好的方法?”

我对 Visual Recognition 知之甚少,对 firebase 也知之甚少。所以,如果有办法更好地处理事情,请说。谢谢!

【问题讨论】:

  • 您需要将图像发送到您的后端吗?还是可以直接从用户传给 Watson?
  • 据我所知,Watson 需要一个链接,仅此而已。所以,我需要生成它。我会搜索一下,看看这是否是唯一的方法。

标签: node.js firebase vue.js ibm-watson visual-recognition


【解决方案1】:

我最终做的是将图像上传到 firebase 存储,将链接发送到服务器,获取结果,然后从 firebase 中删除图像。

【讨论】:

    【解决方案2】:

    根据 API 文档,您可以提交要分类为 url 或 readstream 的图像。 https://cloud.ibm.com/apidocs/visual-recognition/visual-recognition-v3?code=node#classify

    API 文档中提供的示例使用了读取流:

    
    const fs = require('fs');
    const VisualRecognitionV3 = require('ibm-watson/visual-recognition/v3');
    const { IamAuthenticator } = require('ibm-watson/auth');
    
    const visualRecognition = new VisualRecognitionV3({
      version: '2018-03-19',
      authenticator: new IamAuthenticator({
        apikey: '{apikey}',
      }),
      serviceUrl: '{url}',
    });
    
    const classifyParams = {
      imagesFile: fs.createReadStream('./fruitbowl.jpg'),
      owners: ['me'],
      threshold: 0.6,
    };
    
    visualRecognition.classify(classifyParams)
      .then(response => {
        const classifiedImages = response.result;
        console.log(JSON.stringify(classifiedImages, null, 2));
      })
      .catch(err => {
        console.log('error:', err);
      });
    
    

    【讨论】:

    • 是的,你是对的。但是,我最终做的是使用 Firebase,上传它并生成一个链接,将该链接发送到后端并获取结果......并删除 Firebase 存储上的图像。
    猜你喜欢
    • 1970-01-01
    • 2019-12-24
    • 1970-01-01
    • 2019-11-17
    • 1970-01-01
    • 2014-12-10
    • 2020-03-03
    • 1970-01-01
    • 2019-09-26
    相关资源
    最近更新 更多