阿里云人脸识别

这篇博客介绍了如何使用阿里云的老版SDK,具体为facebody20191230版本,来初始化账号Client并进行人脸识别比对操作。示例代码展示了如何设置AccessKey ID和AccessKey Secret,以及调用CompareFace接口进行图片对比,并设置了质量分数阈值。
摘要由CSDN通过智能技术生成

老版SDK
https://www.cnblogs.com/lyraHeartstrings/p/15261909.html

 maven
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>facebody20191230</artifactId>
  <version>2.0.3</version>
</dependency>
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
        return new com.aliyun.facebody20191230.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.facebody20191230.Client client = Sample.createClient("accessKeyId", "accessKeySecret");
        com.aliyun.facebody20191230.models.CompareFaceRequest compareFaceRequest = new com.aliyun.facebody20191230.models.CompareFaceRequest()
                .setQualityScoreThreshold(61.5F)
                .setImageDataA(com.aliyun.teautil.Common.toBytes("/9qwdawdfawd"))
                .setImageDataB(com.aliyun.teautil.Common.toBytes("/afdwafseadfa"));
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // 复制代码运行请自行打印 API 的返回值
            client.compareFaceWithOptions(compareFaceRequest, runtime);
        } catch (TeaException error) {
            // 如有需要,请打印 error
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 如有需要,请打印 error
            com.aliyun.teautil.Common.assertAsString(error.message);
        }        
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值