0.1.1 • Published 6 years ago

tcb-ai v0.1.1

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

腾讯云 - 智能图像服务

产品地址

https://cloud.tencent.com/document/product/641

支持功能

使用事例

以 OCR-身份证识别 为例,一般支持外链 url 或者本地读取图片文件,两种方式。

  • 外链 url
const {
    ImageClient
} = require('../packages/tcb-ai');

let AppId = ''; // 腾讯云 AppId
let SecretId = ''; // 腾讯云 SecretId
let SecretKey = ''; // 腾讯云 SecretKey

let idCardImageUrl = 'http://images.cnitblog.com/blog/454646/201306/07090518-029ff26fac014d72a7786937e8319c78.jpg';
let imgClient = new ImageClient({ AppId, SecretId, SecretKey });
imgClient.ocrIdCard({
    data: {
        url_list: [idCardImageUrl]
    }
}).then((result) => {
    console.log(result.body)
}).catch((e) => {
    console.log(e);
});
  • 读取本地文件
const fs = require('fs');
const path = require('path');
const {
    ImageClient
} = require('../packages/tcb-ai');

let AppId = ''; // 腾讯云 AppId
let SecretId = ''; // 腾讯云 SecretId
let SecretKey = ''; // 腾讯云 SecretKey

let imgClient = new ImageClient({ AppId, SecretId, SecretKey });
imgClient.ocrIdCard({
    formData: {
        card_type: 0,
        image: fs.createReadStream(path.join(__dirname, './idcard.jpg'))
    },
    headers: {
        'content-type': 'multipart/form-data'
    }
}).then((result) => {
    console.log(result.body)
}).catch((e) => {
    console.log(e);
});

运行 example

如果想运行,example/ai.js 下面的例子,请先在项目根目录新建 config/index.js 文件,并按以下格式写下配置

    const ProxyUrl = ''; // 可填公司代理
    const AppId = ''; // 腾讯云 AppId
    const SecretId = ''; // 腾讯云  SecretId
    const SecretKey = ''; // 腾讯云 SecretKey

    exports.ProxyUrl = ProxyUrl;
    exports.AppId = AppId;
    exports.SecretId = SecretId;
    exports.SecretKey = SecretKey;
0.1.1

6 years ago

0.0.3

6 years ago

0.0.1

6 years ago