V3功能调用后提示如下错误
小安安静静 发布于2018-05 浏览:1327 回复:2
1
收藏

// image1/image2也可以为url或facetoken, 相应的imageType参数需要与之对应。
MatchRequest req1 = new MatchRequest(image1, "FACE_TOKEN");
MatchRequest req2 = new MatchRequest(image2, "FACE_TOKEN");
ArrayList requests = new ArrayList();
requests.add(req1);
requests.add(req2);

JSONObject res = client.match(requests);
System.out.println(res.toString(2));

 

收藏
点赞
1
个赞
共2条回复 最后由199******97回复于2018-11
#3199******97回复于2018-11

为什么我的   client.match  会报错啊

0
#2用户已被禁言回复于2018-05

你调用的imagetype为FACE_TOKEN 。那这image1和image2 都应该是一个32定长的固定值。目前来说是32位的

我通过FACE_TOKEN和BASE64都测试过都是没有问题都。

  • 示例代码
package cn.xsshome.face;

import java.util.ArrayList;

import org.json.JSONObject;

import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;

public class FaceV3Sample {
	public static void main(String[] args) throws Exception {
		AipFace aipFace = new AipFace("APPID", "APIKEY", "SECRETKEY");
		String image1 = "a97e438a5a65f8a199a4df3215866208";
		String image2 = "16945cdcad9dc6640245eb2c2a836b2d";
		MatchRequest request1 = new MatchRequest(image1, "FACE_TOKEN");
		MatchRequest request2 = new MatchRequest(image2, "FACE_TOKEN");
		ArrayList arrayList =new ArrayList();
		arrayList.add(request1);
		arrayList.add(request2);
		JSONObject object = aipFace.match(arrayList);
		System.out.println(object.toString(2));
	}
}
  • 输出结果
{
  "result": {
    "score": 10.22895813,
    "face_list": [
      {"face_token": "a97e438a5a65f8a199a4df3215866208"},
      {"face_token": "16945cdcad9dc6640245eb2c2a836b2d"}
    ]
  },
  "log_id": 3604343417,
  "error_msg": "SUCCESS",
  "cached": 0,
  "error_code": 0,
  "timestamp": 1525350728
}

    

1
TOP
切换版块