人脸比对接口调试

master
coco1986509808 2023-03-28 17:47:52 +08:00
parent 6e3ab2612c
commit f3ebd4656c
1 changed files with 22 additions and 5 deletions

View File

@ -160,14 +160,31 @@ public class CompareServiceImpl implements ICompareService {
private void validateSingleFaceImage(String image) {
//人脸检测url
//String faceSearchUrl = apiRequestPrefix + ApiUrlEnum.FACE_SEARCH.getUrl();
String faceSearchUrltest = 192.168.3.132:5000/message/mask;
String faceSearchUrltest ="http://192.168.3.132:5000/message/mask";
//组装api请求数据
ReturnVO returnVO;
returnVO = (ReturnVO) httpUtil.post(faceSearchUrltest + "?url=" + image, null, ReturnVO.class);
if (returnVO.getCode() != 200) {
throw new DkException(returnVO.getMessage());
}
returnVO = (ReturnVO) httpUtil.post(faceSearchUrltest + "?url=" + image, null, ReturnVO.class);
System.out.println(returnVO.getCode()+returnVO.getMessage());
if (returnVO.getCode() != 200) {
throw new DkException(returnVO.getMessage());
}
//反序列化
// 返回data格式{
// "code": 200,
// "data": [
// {
// "faceRect": {
// "h": 174,
// "w": 257,
// "x": 161,
// "y": 47
// },
// "url": "http://192.168.1.133:9000/middleware/456/1790226920.jpg"
// }
// ],
// "message": "检测到人脸"
//}
List<ApiSearchFaceRectVO> apiSearchFaceRectVOList = JsonUtil.string2Obj(JsonUtil.obj2String(returnVO.getData()), new TypeReference<List<ApiSearchFaceRectVO>>() {});
if (UtilValidate.isEmpty(apiSearchFaceRectVOList)) {
throw new DkException("当前上传中未检测到人脸,请重新上传");