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

作者阿里云代理 文章分类 分类:linux图文教程 阅读次数 已被围观 1133

Step By Step

1.开通人脸人体服务。

人脸人体
image.png

2.获取您的真实AK信息

查看AK
image.png

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.运行结果
image.png

 

本公司销售:阿里云新/老客户,只要购买阿里云,即可享受折上折优惠!>

我有话说: