1.0.7 • Published 5 years ago

image-node-sdk v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

腾讯云 - 智能图像服务

NPM Version Travis Deps

安装

npm i --save image-node-sdk

配置

可以设置以下环境变量,这样就不需要传入 AppId, SecretIDSecretKey 了。

process.env.TENCENTCLOUD_APPID
process.env.TENCENTCLOUD_SECRETID
process.env.TENCENTCLOUD_SECRETKEY

// 或
process.env.APPID
process.env.SECRETID
process.env.SECRETKEY

使用

以 创建人员 为例,一般支持外链 url 或者本地读取图片文件,两种方式。

  • 外链 url
const {
    ImageClient
} = require('image-node-sdk');

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

let Url = 'https://www.google.com.hk/url?sa=i&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjX9Pv-s8XgAhWZKqYKHY2WCOcQjRx6BAgBEAU&url=https%3A%2F%2Fkuaibao.qq.com%2Fs%2F20180506A0GUC600%3Frefer%3Dspider&psig=AOvVaw1hxiMNF_ZVQZvkVu11xNNf&ust=1550580081217063';
let imgClient = new ImageClient({ AppId, SecretId, SecretKey });
imgClient.init({
    action: 'CreatePerson',
    data: {
        GroupId: 'mengmeiqi-01',
        PersonName: '孟美歧',
        PersonId: 'mengmeiqi-0001',
        Url,
    }
}).then((result) => {
    console.log(result.body)
}).catch((e) => {
    console.log(e);
});
  • 读取本地文件
const fs = require('fs');
const path = require('path');
const {
    ImageClient
} = require('image-node-sdk');

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

let imgClient = new ImageClient({ AppId, SecretId, SecretKey });
imgClient.init({
    action: 'CreatePerson',
    data: {
        GroupId: 'mengmeiqi-01',
        PersonName: '孟美歧',
        PersonId: 'mengmeiqi-0001',
        Image: fs.readFileSync(path.join(__dirname, '../config/mengmeiqi-0001.jpeg')).toString('base64'),
    }
}).then((result) => {
    console.log(result.body)
}).catch((e) => {
    console.log(e);
});

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

const ProxyUrl = ''; // 可填公司代理
const AppId = ''; // 腾讯云 AppId
const SecretId = ''; // 腾讯云  SecretId
const SecretKey = ''; // 腾讯云 SecretKey
const IdCard = ''; // 身份证号码,用于人脸核身
const Name = ''; // 身份证姓名,用于人脸核身


const ProxyUrl = ''; // 可填公司代理
const AppId = ''; // 腾讯云 AppId
const SecretId = ''; // 腾讯云  SecretId
const SecretKey = ''; // 腾讯云 SecretKey
const IdCard = ''; // 身份证号码,用于人脸核身
const Name = ''; // 身份证姓名,用于人脸核身

exports.ProxyUrl = ProxyUrl;
exports.AppId = AppId;
exports.SecretId = SecretId;
exports.SecretKey = SecretKey;
exports.IdCard = IdCard;
exports.Name = Name;

支持功能

更新日志

日志

声明

测试用的身份证源于该文章的实验身份证,如有侵权,请联系作者删除。