文档首页 > > SDK参考> CSharp SDK> SDK接口示例

SDK接口示例

分享
更新时间: 2020/03/19 GMT+08:00

V1版本SDK示例

  1. 构造服务客户端
    1
    2
    3
    4
    AuthInfo authInfo = new AuthInfo("https://face.cn-north-4.myhuaweicloud.com", "ak", "sk");
    FrsClient frsClient = new FrsClient(authInfo, "project id");
    //ProxyHostInfo proxy := new ProxyHostInfo("host", 8080);
    //FrsClient frsClient = new FrsClient (authInfo, "projectId", proxy);//当您需要代理才可以访问到服务时,在第三个参数增加代理信息即可
    
  2. 创建人脸集
    1
    2
    3
    4
    5
    CreateExternalFields createExternalFields = new CreateExternalFields();
    createExternalFields.AddField("testInt", FieldType.INTEGER);
    createExternalFields.AddField("testStr", FieldType.STRING);
    CreateFaceSetResult createFaceSetResult = frsClient.GetFaceSetService().CreateFaceSet("face_set_name_test", 10000, createExternalFields);
    Console.WriteLine(createFaceSetResult.GetJsonString());
    
  3. 添加人脸
    1
    2
    3
    4
    5
    AddExternalFields addExternalFields = new AddExternalFields();
    addExternalFields.AddField("testInt", 1);
    addExternalFields.AddField("testStr", "str");
    AddFaceResult addFaceResult = frsClient.GetFaceService().AddFaceByFile("face_set_name_test", "/resource/3.png", addExternalFields);
    Console.WriteLine(addFaceResult.GetJsonString());
    
  4. 人脸检测
    1
    2
    3
    4
    DetectFaceResult detectFaceResult = frsClient.GetDetectService().DetectFaceByUrl("/obs/1.jpg", "0,1,2");
    Console.WriteLine(detectFaceResult.GetJsonString());
    DetectFaceResult detectFaceResult2 = frsClient.GetDetectService().DetectFaceByFile("/resource/1.jpeg", "1,2");
    Console.WriteLine(detectFaceResult2.GetJsonString());
    

V2版本SDK示例

  1. 构造服务客户端
    1
    2
    3
    4
    AuthInfo authInfo = new AuthInfo("https://face.cn-north-4.myhuaweicloud.com", "ak", "sk");
    FrsClient frsClient = new FrsClient(authInfo, "project id");
    //ProxyHostInfo proxy := new ProxyHostInfo("host", 8080);
    //FrsClient frsClient = new FrsClient (authInfo, "projectId", proxy);//当您需要代理才可以访问到服务时,在第三个参数增加代理信息即可
    
  2. 创建人脸集
    1
    2
    3
    4
    5
    CreateExternalFields createExternalFields = new CreateExternalFields();
    createExternalFields.AddField("testInt", FieldType.INTEGER);
    createExternalFields.AddField("testStr", FieldType.STRING);
    CreateFaceSetResult createFaceSetResult = frsClient.GetV2().GetFaceSetService().CreateFaceSet("face_set_name_test", 10000, createExternalFields);
    Console.WriteLine(createFaceSetResult.GetJsonString());
    
  3. 添加人脸
    1
    2
    3
    4
    5
    AddExternalFields addExternalFields = new AddExternalFields();
    addExternalFields.AddField("testInt", 1);
    addExternalFields.AddField("testStr", "str");
    AddFaceResult addFaceResult = frsClient.GetV2().GetFaceService().AddFaceByFile("face_set_name_test", "/resource/3.png", addExternalFields);
    Console.WriteLine(addFaceResult.GetJsonString());
    
  4. 人脸检测
    1
    2
    3
    4
    DetectFaceResult detectFaceResult = frsClient.GetV2().GetDetectService().DetectFaceByUrl("/obs/1.jpg", "0,1,2");
    Console.WriteLine(detectFaceResult.GetJsonString());
    DetectFaceResult detectFaceResult2 = frsClient.GetV2().GetDetectService().DetectFaceByFile("/resource/1.jpeg", "1,2");
    Console.WriteLine(detectFaceResult2.GetJsonString());
    
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问