阿里云视觉智能开放平台人脸人体API Net SDK Quick Start

Step By Step

1、API官方说明
2、Open API Exployer使用快速开始
3、老版本NET SDK安装及使用
4、新版本NET SDK安装及使用


1、CompareFace API官方说明
人脸比对1:1
2、Open API Exployer使用快速开始
快速测试地址:CompareFace

阿里云视觉智能开放平台人脸人体API Net SDK Quick Start

阿里云视觉智能开放平台人脸人体API Net SDK Quick Start

3、老版本NET SDK安装及使用
  • 3.1 nuget安装sdk:aliyun-net-sdk-facebody

阿里云视觉智能开放平台人脸人体API Net SDK Quick Start

  • 3.2 Code Sample
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using System;

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            IClientProfile profile = DefaultProfile.GetProfile("cn-shanghai", "<accesskey>", "<accesssecret>");
            DefaultAcsClient client = new DefaultAcsClient(profile);
            CommonRequest request = new CommonRequest();
            request.Method = MethodType.POST;
            request.Domain = "facebody.cn-shanghai.aliyuncs.com";
            request.Version = "2019-12-30";
            request.Action = "CompareFace";
            // request.Protocol = ProtocolType.HTTP;
            request.AddQueryParameters("QualityScoreThreshold", "60");
            request.AddQueryParameters("ImageURLA", "https://taro-tensorflow.oss-cn-shanghai.aliyuncs.com/face/jingtian1.jpeg");
            request.AddQueryParameters("ImageURLB", "https://taro-tensorflow.oss-cn-shanghai.aliyuncs.com/face/jingtian2.jpeg");
            try
            {
                CommonResponse response = client.GetCommonResponse(request);
                Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
            }
            catch (ServerException e)
            {
                Console.WriteLine(e);
            }
            catch (ClientException e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }
    }
}
  • 3.3 Result
{"RequestId":"FADC78F0-5C94-522E-B089-43AD********","Data":{"QualityScoreA":99.9901123046875,"QualityScoreB":95.234146118164062,"Thresholds":[61.0,69.0,75.0],"Confidence":83.987808227539062,"RectAList":[175,107,177,222],"RectBList":[167,76,170,219]}}
4、新版本NET SDK安装及使用
  • 4.1 nuget安装sdk:AlibabaCloud.SDK.Facebody20191230

阿里云视觉智能开放平台人脸人体API Net SDK Quick Start

  • 4.2 Code Sample
using AlibabaCloud.SDK.Facebody20191230.Models;
using System;

namespace ConsoleApp10
{
    class Program
    {
        public static AlibabaCloud.SDK.Facebody20191230.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // 您的AccessKey ID
                AccessKeyId = accessKeyId,
                // 您的AccessKey Secret
                AccessKeySecret = accessKeySecret,
            };
            // 访问的域名
            config.Endpoint = "facebody.cn-shanghai.aliyuncs.com";
            return new AlibabaCloud.SDK.Facebody20191230.Client(config);
        }
        static void Main(string[] args)
        {
            AlibabaCloud.SDK.Facebody20191230.Client client = CreateClient("<accesskey>", "<accesssecret>");
            CompareFaceRequest compareFaceRequest = new CompareFaceRequest
            {
                QualityScoreThreshold = 60f,
                ImageURLA = "https://taro-tensorflow.oss-cn-shanghai.aliyuncs.com/face/jingtian1.jpeg",
                ImageURLB = "https://taro-tensorflow.oss-cn-shanghai.aliyuncs.com/face/jingtian2.jpeg",
            };
            // 复制代码运行请自行打印 API 的返回值
            CompareFaceResponse compareFaceResponse = client.CompareFace(compareFaceRequest);
            Console.WriteLine(compareFaceResponse.Body.Data.RectAList.Count);
            Console.WriteLine(compareFaceResponse.Body.Data.Confidence);

            Console.ReadKey();
        }
    }
}
  • 4.3 Result
4
83.98781

更多参考

阿里云视觉智能开放平台--人脸识别使用教程
accesskey&accesssecret获取参考

上一篇:Spring Cloud Zuul的动态路由怎样做?集成Nacos实现很简单


下一篇:阿里云机器学习ModelHub使用Quick Start