阿里云视觉智能开放平台人脸人体中人脸属性识别Java调用

Step By Step

1.开通人脸人体服务。

人脸人体
阿里云视觉智能开放平台人脸人体中人脸属性识别Java调用

2.获取您的真实AK信息

查看AK
阿里云视觉智能开放平台人脸人体中人脸属性识别Java调用

3.添加java依赖

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>facebody20191230</artifactId>
  <version>2.0.1</version>
</dependency>
<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.5.13</version>
</dependency>

4.Java SDK Code



import com.aliyun.tea.*;
import com.aliyun.facebody20191230.*;
import com.aliyun.facebody20191230.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;
import com.google.gson.Gson;

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 {
        Config config = new 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("ak", "sk");
        RecognizeFaceRequest recognizeFaceRequest = new RecognizeFaceRequest()
                .setImageURL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/RecognizeFace/RecognizeFace1.png")
                .setAge(true);
        // 复制代码运行请自行打印 API 的返回值
        client.recognizeFace(recognizeFaceRequest);
        RecognizeFaceResponse response =client.recognizeFace(recognizeFaceRequest);
        System.out.println(new Gson().toJson(response));
    }
}

####5.运行结果
阿里云视觉智能开放平台人脸人体中人脸属性识别Java调用

参考链接

人脸属性识别

上一篇:飞天加速计划·高校学生在家实践——ECS服务器初体验


下一篇:独家揭秘 | 阿里怎么做双11全链路压测?