BASE64Encoder base64Encoder =new BASE64Encoder();
String base64 = base64Encoder.encode(file.getBytes());
- js拍照api
takePhoto() {
var that = this;
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'normal',
success: (res) => {
this.setData({
src: res.tempImagePath
})
console.log("file", res);
this.uploadPhoto();
}
})
wx.showToast({
title: '正在检测人脸',
icon: 'loading',
duration: 1000
})
},
- controller
@ApiOperation(value = "查找是否存在人脸", notes = "查找是否存在人脸", httpMethod = "POST")
@PostMapping(value = "/search")
public String searchFace(MultipartFile file, @RequestParam HashMap<String, String> params) throws IOException {
return aipFaceSevice.searchFace(file,params);
}
- service
@Override
public String searchFace(MultipartFile file, HashMap<String, String> params) throws IOException {
BASE64Encoder base64Encoder =new BASE64Encoder();
String base64 = base64Encoder.encode(file.getBytes());
HashMap<String, String> options = new HashMap<String, String>();
options.put("max_face_num", "3");
options.put("match_threshold", "70");
options.put("quality_control", "NORMAL");
options.put("liveness_control", "LOW");
options.put("max_user_num", "3");
String image = base64;
String imageType = "BASE64";
String groupIdList = "meet";
JSONObject res = client.search(image, imageType, groupIdList, options);
return res.toString();
}