|
@@ -147,8 +147,8 @@ public class FaceServiceImpl implements FaceService {
|
|
String facesetToken = getFacesetToken(rootOrgId);
|
|
String facesetToken = getFacesetToken(rootOrgId);
|
|
info.put("facesetToken", facesetToken);
|
|
info.put("facesetToken", facesetToken);
|
|
|
|
|
|
- if (times > 5) {
|
|
|
|
- LOG.error("添加faceToken至faceSet失败. info=" + JsonUtil.toJson(info));
|
|
|
|
|
|
+ if (times > 3) {
|
|
|
|
+ LOG.error("添加faceToken至faceSet失败. info:{}", JsonUtil.toJson(info));
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -170,8 +170,7 @@ public class FaceServiceImpl implements FaceService {
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
|
|
|
|
- LOG.info(
|
|
|
|
- "[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
+ LOG.info("[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
if (respBody.contains("QUOTA_EXCEEDED")) {
|
|
if (respBody.contains("QUOTA_EXCEEDED")) {
|
|
throw new StatusException("620006", "faceset is full");
|
|
throw new StatusException("620006", "faceset is full");
|
|
@@ -196,7 +195,7 @@ public class FaceServiceImpl implements FaceService {
|
|
times++;
|
|
times++;
|
|
continue;
|
|
continue;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- LOG.error("调用addface接口异常. info=" + JsonUtil.toJson(info), e);
|
|
|
|
|
|
+ LOG.error("添加faceToken接口异常. info:{} errCount:{} err:{}" + JsonUtil.toJson(info), times, e.getMessage());
|
|
times++;
|
|
times++;
|
|
continue;
|
|
continue;
|
|
} finally {
|
|
} finally {
|
|
@@ -239,9 +238,11 @@ public class FaceServiceImpl implements FaceService {
|
|
int times = 0;
|
|
int times = 0;
|
|
String faceToken = null;
|
|
String faceToken = null;
|
|
while (true) {
|
|
while (true) {
|
|
- if (times > 5) {
|
|
|
|
|
|
+ if (times > 3) {
|
|
|
|
+ LOG.error("人脸检测失败. photoUrl:{}", photoUrl);
|
|
throw new StatusException("620005", "人脸检测失败");
|
|
throw new StatusException("620005", "人脸检测失败");
|
|
}
|
|
}
|
|
|
|
+
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
CloseableHttpResponse httpResponse = null;
|
|
CloseableHttpResponse httpResponse = null;
|
|
try {
|
|
try {
|
|
@@ -250,8 +251,7 @@ public class FaceServiceImpl implements FaceService {
|
|
.setParameter("api_secret", apiSecret).setParameter("image_url", photoUrl)
|
|
.setParameter("api_secret", apiSecret).setParameter("image_url", photoUrl)
|
|
.build();
|
|
.build();
|
|
|
|
|
|
- LOG
|
|
|
|
- .info("[Face++ Rquest]. url=" + uri.toString() + "; photoUrl=" + photoUrl);
|
|
|
|
|
|
+ LOG.info("[Face++ Rquest]. url=" + uri.toString() + "; photoUrl=" + photoUrl);
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
|
|
|
|
@@ -260,14 +260,13 @@ public class FaceServiceImpl implements FaceService {
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
String respBody = EntityUtils.toString(entity, "UTF-8");
|
|
|
|
|
|
- LOG.info(
|
|
|
|
- "[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
+ LOG.info("[Face++ Response]. statusCode=" + statusCode + "; respBody=" + respBody);
|
|
|
|
|
|
if (statusCode == HttpStatus.SC_OK) {
|
|
if (statusCode == HttpStatus.SC_OK) {
|
|
JSONObject jsonObject = JSON.parseObject(respBody);
|
|
JSONObject jsonObject = JSON.parseObject(respBody);
|
|
JSONArray faces = jsonObject.getJSONArray("faces");
|
|
JSONArray faces = jsonObject.getJSONArray("faces");
|
|
if (1 != faces.size()) {
|
|
if (1 != faces.size()) {
|
|
- throw new StatusException("620009", "检测到多张人脸. photoUrl=" + photoUrl);
|
|
|
|
|
|
+ throw new StatusException("620009", "检测人脸数量不正确. photoUrl=" + photoUrl);
|
|
}
|
|
}
|
|
|
|
|
|
JSONObject face = faces.getJSONObject(0);
|
|
JSONObject face = faces.getJSONObject(0);
|
|
@@ -282,7 +281,7 @@ public class FaceServiceImpl implements FaceService {
|
|
times++;
|
|
times++;
|
|
continue;
|
|
continue;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- LOG.error("调用detect接口异常. photoUrl=" + photoUrl, e);
|
|
|
|
|
|
+ LOG.error("人脸检测接口异常. photoUrl:{} errCount:{} err:{}", photoUrl, times, e.getMessage());
|
|
times++;
|
|
times++;
|
|
continue;
|
|
continue;
|
|
} finally {
|
|
} finally {
|