tencentyun-youtu-java
java sdk for 腾讯优图开放平台
名词
AppId平台添加应用后分配的AppIdSecretId平台添加应用后分配的SecretIdSecretKey平台添加应用后分配的SecretKey签名接口鉴权凭证,由AppId、SecretId、SecretKey等生成,详见http://open.youtu.qq.com/#/develop/tool-authentication
使用方法
- 下载sdk到您的目录 git clone https://github.com/Tencent-YouTu/java_sdk.git
- 在你的项目里引入本项目dist目录下的json.jar和youtu-java-sdk.jar包或者直接引入源码
- 导入包并创建Youtu对象,然后调用相应方法
使用示例
import org.json.JSONObject;
import com.youtu.*;
设置APP 鉴权信息
public static final String APP_ID = "your appid";
public static final String SECRET_ID = "your secretId ";
public static final String SECRET_KEY = "your secretKey ";
public static final String USER_ID = "your qq ";
根据你使用的平台选择一种初始化方式
- 优图开放平台初始化
Youtu faceYoutu = new Youtu(APP_ID, SECRET_ID, SECRET_KEY,Youtu.API_YOUTU_END_POINT,USER_ID);
- 优图开放平台核身服务初始化(核身服务目前仅支持核身专有接口,需要联系商务开通)
Youtu faceYoutu = new Youtu(APP_ID, SECRET_ID, SECRET_KEY,Youtu.API_YOUTU_CHARGE_END_POINT,USER_ID);
- 腾讯云初始化方式
Youtu faceYoutu = new Youtu(APP_ID, SECRET_ID, SECRET_KEY,Youtu.API_TENCENTYUN_END_POINT,USER_ID);
- 人脸检测调用示例
JSONObject response = faceYoutu.DetectFace("test.jpg");
- 获取详细信息
if(response.getInt("errorcode")==0){
System.out.println(response.get("image_height"));
System.out.println(response.get("face"));
System.out.println(response.getJSONArray("face").getJSONObject(0).get("yaw"));
System.out.println(response.getInt("errorcode"));
System.out.println(response.get("errormsg"));
}
Api分为开放平台API和核身API,核身API访问权限需要联系商务开通;开放平台API访问域名为https://api.youtu.qq.com/, 核身API访问域名为https://vip-api.youtu.qq.com/
核身API介绍
优图开放平台相关核身API封装,均为同步函数,需要联系商务开通 接口调用统一返回值说明
- 返回值类型为
JSONObject,具体字段参考API文档
获取四字唇语
- 接口
JSONObject LiveGetFour() - 参数
- 无
带数据源四字人脸核身
- 接口
JSONObject LiveDetectFour(String validate_data,String video_path,String card_path,boolean compare_card) - 参数
validate_dataLiveGetFour获取的四字唇语video_path视频的路径card_path对比照片的路径compare_card视频与照片是否进行对比,true 对比 false不对比
不带数据源四字人脸核身
- 接口
JSONObject IdcardLiveDetectfour(String idcard_number,String idcard_name,String validate_data,String video_path) - 参数
idcard_number身份证号码idcard_name身份证姓名validate_dataLiveGetFour获取的四字唇语video_path视频的路径
不带数据源人脸对比
- 接口
JSONObject IdcardFaceCompare(String idcard_number,String idcard_name,String image_path) - 参数
idcard_number身份证号码idcard_name身份证姓名image_path照片的路径
验证身份证信息的有效性
- 接口
JSONObject ValidateIdcard(String idcard_number,String idcard_name) - 参数
idcard_number身份证号码idcard_name身份证姓名
人脸比对
- 接口
JSONObject FaceCompare(String image_path_a, String image_path_b)JSONObject FaceCompareUrl(String urlA, String urlB) - 参数
image_path_a待检测的图片A路径image_path_b待检测的图片B路径urlA待检测的图片A的urlurlB待检测的图片B的url
身份证OCR
- 接口
JSONObject IdCardOcr(String image_path, int card_type)JSONObject IdCardOcrUrl(String url, int card_type) - 参数
image_path待检测图片路径url待检测图片的urlcard_type0 代表输入图像是身份证正面, 1代表输入是身份证反面
开放平台API介绍
优图开放平台相关API封装,均为同步函数 接口调用统一返回值说明
- 返回值类型为
JSONObject,具体字段参考API文档
人脸检测
- 接口
JSONObject DetectFace(String image_path,int mode)JSONObject DetectFaceUrl(String url, int mode) - 参数
image_path待检测的图片路径url待检测的图片urlmode是否大脸模式,1为大脸、0为非大脸
人脸配准
- 接口
JSONObject FaceShape(String image_path,int mode)JSONObject FaceShapeUrl(String url,int mode) - 参数
image_path待检测的图片路径mode是否大脸模式,1为大脸、0为非大脸
人脸比对
- 接口
JSONObject FaceCompare(String image_path_a, String image_path_b)JSONObject FaceCompareUrl(String urlA, String urlB) - 参数
image_path_a待检测的图片A路径image_path_b待检测的图片B路径urlA待检测的图片A的urlurlB待检测的图片B的url
人脸验证
- 接口
JSONObject FaceVerify(String image_path, String person_id)JSONObject FaceVerifyUrl(String url, String person_id) - 参数
person_id待验证的人脸idurl待检测的图片urlimage_path待验证的图片路径
人脸识别
- 接口
JSONObject FaceIdentify(String image_path, String group_id)JSONObject FaceIdentifyUrl(String url, String group_id) - 参数
group_id待识别的组idurl待检测的图片urlimage_path待识别的图片数据路径
多人脸检索
- 接口
JSONObject MultiFaceIdentify(String image_path, String group_id, List<String> group_ids)JSONObject MultiFaceIdentifyUrl(String url, String group_id, List<String> group_ids)JSONObject MultiFaceIdentify(String image_path, String group_id, List<String> group_ids, int topn, int min_size)JSONObject MultiFaceIdentifyUrl(String url, String group_id, List<String> group_ids, int topn, int min_size) - 参数
group_id识别的组idgroup_ids识别的个体存放的组id,可以指定多个组id,用户指定topn候选人脸数量,一般使用默认值5min_size人脸检测最小尺寸,一般使用默认值40
新建个体
- 接口
JSONObject NewPerson(String image_path, String person_id, List<String> group_ids)JSONObject NewPersonUrl(String url, String person_id,List<String> group_ids) - 参数
person_id新建的个体id,用户指定,需要保证app_id下的唯一性person_name新建的个体名称group_ids新建的个体存放的组id,可以指定多个组id,用户指定(组默认创建)url待检测的图片urlimage_path包含个体人脸的图片路径tag备注信息,用户自解释字段
删除个体
- 接口
JSONObject DelPerson(String person_id) - 参数
person_id待删除的个体id
增加人脸
- 接口
JSONObject AddFace(String person_id, List<String> image_path_arr)JSONObject AddFaceUrl(String person_id, List<String> url_arr) - 参数
person_id新增人脸的个体身份idurl_arr待检测的图片url构成的数组image_path_arr待增加的包含人脸的图片数据的路径,可加入多张(总包体大小<2m)
删除人脸
- 接口
JSONObject DelFace(String person_id, List<String> face_id_arr) - 参数
person_id待删除人脸的个体身份idface_id_arr待删除的人脸id集合
获取信息
- 接口
JSONObject GetInfo(String person_id) - 参数
person_id待查询的个体身份id
设置信息
- 接口
JSONObject SetInfo(String person_name, String person_id) - 参数
person_id待设置的个体身份idperson_name新设置的个体名字
获取组列表
- 接口
JSONObject GetGroupIds() - 参数
- 无
获取个体列表
- 接口
JSONObject GetPersonIds(String group_id) - 参数
group_id待查询的组id
获取人脸列表
- 接口
JSONObject GetFaceIds(String person_id) - 参数
person_id待查询的个体id
获取人脸信息
- 接口
JSONObject GetFaceInfo(String face_id) - 参数
face_id待查询人脸的id
判断一个图像的模糊程度
- 接口
JSONObject FuzzyDetect(String image_path)JSONObject FuzzyDetectUrl(String url) - 参数
url待检测的图片urlimage_path待识别的图片数据路径
识别一个图像是否为美食图像
- 接口
JSONObject FoodDetect(String image_path)JSONObject FoodDetectUrl(String url) - 参数
url待检测的图片urlimage_path待识别的图片数据路径
识别一个图像的标签信息,对图像分类
- 接口
JSONObject ImageTag(String image_path)JSONObject ImageTagUrl(String url) - 参数
url待检测的图片urlimage_path待识别的图片数据路径
色情图像检测
- 接口
JSONObject ImagePorn(String image_path)JSONObject ImagePornUrl(String url) - 参数
image_path待识别的图片数据路径url待检测的图片url
暴恐图片识别
- 接口
JSONObject ImageTerrorism(String image_path)JSONObject ImageTerrorismUrl(String url) - 参数
image_path待识别的图片数据路径url待检测的图片url
车辆属性识别
- 接口
JSONObject CarClassify(String image_path)JSONObject CarClassifyUrl(String url) - 参数
image_path待识别的图片数据路径url待检测的图片url
身份证OCR
- 接口
JSONObject IdCardOcr(String image_path, int card_type)JSONObject IdCardOcrUrl(String url, int card_type) - 参数
image_path待检测图片路径url待检测图片的urlcard_type0 代表输入图像是身份证正面, 1代表输入是身份证反面
通用OCR
- 接口
JSONObject GeneralOcr(String image_path)JSONObject GeneralOcrUrl(String url) - 参数
image_path待检测图片路径url待检测图片的url
名片OCR
- 接口
JSONObject BcOcr(String image_path)JSONObject BcOcrUrl(String url) - 参数
image_path待检测图片路径url待检测图片的url
行驶证&驾驶证OCR
- 接口
JSONObject DriverLicenseOcr(String image_path, int card_type)JSONObject DriverLicenseOcrUrl(String url, int card_type) - 参数
image_path待检测图片路径url待检测图片的urlcard_type0 代表输入图像是行驶证, 1代表输入图像是驾驶证
银行卡OCR识别
- 接口
JSONObject CreditCardOcr(String image_path)JSONObject CreditCardOcrUrl(String url) - 参数
image_path待检测图片路径url待检测图片的url
营业执照OCR识别
- 接口
JSONObject BizLicenseOcr(String image_path)JSONObject BizLicenseOcrUrl(String url) - 参数
image_path待检测图片路径url待检测图片的url
车牌OCR识别
- 接口
JSONObject PlateOcr(String image_path)JSONObject PlateOcrUrl(String url) - 参数
image_path待检测图片路径url待检测图片的url
####更多详情和文档说明参见