天天看點

阿裡雲智能視覺開放平台人臉人體API測試Demo

Step By Step

1、API介紹

2、Open API Exployer快速校驗測試

3、Java SDK測試

  • 功能描述
廚師帽檢測可以檢測明廚亮竈場景中廚師帽佩戴情況。
  • 應用場景
名廚亮竈工程:識别餐飲企業廚房中廚師是否在工作中佩戴好廚師帽。
API說明廚師帽檢測 API Exployer快速測試位址
阿裡雲智能視覺開放平台人臉人體API測試Demo
  • 3.1 pom.xml
<dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>facebody20191230</artifactId>
            <version>1.0.15</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-openapi</artifactId>
            <version>0.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-console</artifactId>
            <version>0.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea-util</artifactId>
            <version>0.2.13</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>tea</artifactId>
            <version>[1.1.13, 2.0.0)</version>
        </dependency>           
  • 3.2 CodeSample
import com.aliyun.facebody20191230.models.DetectChefCapRequest;
import com.aliyun.facebody20191230.models.DetectChefCapResponse;
import com.aliyun.teaopenapi.models.*;

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("LT********", "R2DO**********");
        DetectChefCapRequest detectChefCapRequest = new DetectChefCapRequest()
                .setImageURL("https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/xuhan/facebody/DetectChefCap/ChefCap1.png");
        // 複制代碼運作請自行列印 API 的傳回值
          DetectChefCapResponse detectChefCapResponse = client.detectChefCap(detectChefCapRequest);
        System.out.println("confidence:" + detectChefCapResponse.getBody().getData().getElements().iterator().next().confidence);
        System.out.println("category:" + detectChefCapResponse.getBody().getData().getElements().iterator().next().category);
    }
}           
  • 3.3 測試結果
confidence:0.68170947
category:chefcap           

更多參考

阿裡雲視覺智能開放平台--人臉識别使用教程