C#,client.Detect()方法报错
一万六一一 发布于2018-06 浏览:2803 回复:1
1
收藏
最后编辑于2018-06

人脸识别C#sdk,client.Detect()方面要求至少填写两个string类型的数据,而官网教程则填了一个byte[]类型的数据,直接报错,我不知道是我的问题还是教程的问题

收藏
点赞
1
个赞
共1条回复 最后由用户已被禁言回复于2018-06
#2用户已被禁言回复于2018-06

http://ai.baidu.com/docs#/Face-Csharp-SDK-V2/top

  • V2官网示例SDK代码
public void DetectDemo() {
	var image = File.ReadAllBytes("图片文件路径");
	// 调用人脸检测,可能会抛出网络等异常,请使用try/catch捕获
	var result = client.Detect(image);
	Console.WriteLine(result);
	// 如果有可选参数
	var options = new Dictionary{
	    {"max_face_num", 2},
	    {"face_fields", "age"}
	};
	// 带参数调用人脸检测
	result = client.Detect(image, options);
	Console.WriteLine(result);
}

http://ai.baidu.com/docs#/Face-Csharp-SDK/274b74c0 

  • V3官网示例SDK代码
public void DetectDemo() {
	var image = "取决于image_type参数,传入BASE64字符串或URL字符串或FACE_TOKEN字符串";
	
	var imageType = "BASE64";
	
	// 调用人脸检测,可能会抛出网络等异常,请使用try/catch捕获
	var result = client.Detect(image, imageType);
	Console.WriteLine(result);
	// 如果有可选参数
	var options = new Dictionary{
	    {"face_field", "age"},
	    {"max_face_num", 2},
	    {"face_type", "LIVE"}
	};
	// 带参数调用人脸检测
	result = client.Detect(image, imageType, options);
	Console.WriteLine(result);
}

V2 V3版本的我都看了一下。示例代码都没有只写一个参数的。不知道您是看哪里的接口文档。

如果是新创建的应用。应该只有V3版本接口的权限。就是需要填写3个参数的示例代码。文档也选择Http SDK文档-v3再选择C#的即可

 

2
TOP
切换版块