Commit e1e820ff by 朱海

[chg]红线展示修改

1 parent 62095cd9
...@@ -1046,167 +1046,33 @@ public class ReidService { ...@@ -1046,167 +1046,33 @@ public class ReidService {
if (null == picId) { if (null == picId) {
return JsonMessageUtil.getErrorJsonMsg("picId不能为空"); return JsonMessageUtil.getErrorJsonMsg("picId不能为空");
} }
try {
Feature feature = storageUtils.getFeatureByPic(picId); Feature feature = storageUtils.getFeatureByPic(picId);
if (null == feature) { if (null == feature) {
JsonMessageUtil.getErrorJsonMsg("获取特征失败"); JsonMessageUtil.getErrorJsonMsg("获取特征失败");
} }
Integer image_w = 1920;
Integer image_h = 1080;
double zero_point[] = {0, 0};
Integer quadrant = 0;
try {
double cx = feature.getFace_roi().get(0).getX(); double cx = feature.getFace_roi().get(0).getX();
double cy = feature.getFace_roi().get(0).getY(); double cy = feature.getFace_roi().get(0).getY();
double foot_x = feature.getFace_roi().get(0).getW(); double foot_x = feature.getFace_roi().get(0).getW();
double foot_y = feature.getFace_roi().get(0).getH(); double foot_y = feature.getFace_roi().get(0).getH();
Integer img_type = feature.getBody_roi().get(0).getX(); Integer img_type = feature.getBody_roi().get(0).getX();
double gap = 0; Integer quadrant = feature.getBody_roi().get(0).getY();
double lefttop_x = feature.getBody_roi().get(0).getW();
// 计算图像位置 double lefttop_y = feature.getBody_roi().get(0).getH();
if (cx > image_w / 2 + 420) {
quadrant = 1; Integer head_x_inSmall = new Double(Math.abs(cx - lefttop_x)).intValue();
} else if (cx < image_w / 2 - 420) { Integer head_y_inSmall = new Double(Math.abs(cy - lefttop_y)).intValue();
quadrant = 3; Integer foot_x_inSmall = new Double(Math.abs(foot_x - lefttop_x)).intValue();
} else if (cy > image_h / 2) { Integer foot_y_inSmall = new Double(Math.abs(foot_y - lefttop_y)).intValue();
quadrant = 2;
} if (quadrant == 1 || quadrant == 3) {
int temp;
Integer bodyWidth = 80; temp = head_x_inSmall;
Integer headSize = 120; head_x_inSmall = head_y_inSmall;
Integer basic_length = 340; head_y_inSmall = temp;
if (img_type == 9999) { temp = foot_x_inSmall;
bodyWidth = 120; foot_x_inSmall = foot_y_inSmall;
headSize = 120; foot_y_inSmall = temp;
basic_length = 380;
}
if (cx < foot_x) {
cx -= headSize;
foot_x += bodyWidth;
} else {
cx += headSize;
foot_x -= bodyWidth;
}
if (cy < foot_y) {
cy -= headSize;
foot_y += bodyWidth;
} else {
cy += headSize;
foot_y -= bodyWidth;
}
if (cx > foot_x) {
gap = cx - foot_x;
if (cx - foot_x <= basic_length) {
cx = cx + (basic_length - gap) * 0.5;
foot_x = foot_x - (basic_length - gap) * 0.5;
}
} else {
gap = foot_x - cx;
if (foot_x - cx <= basic_length) {
cx = cx - (basic_length - gap) * 0.5;
foot_x = foot_x + (basic_length - gap) * 0.5;
}
}
if (cy > foot_y) {
gap = cy - foot_y;
if (cy - foot_y <= basic_length) {
cy = cy + (basic_length - gap) * 0.5;
foot_y = foot_y - (basic_length - gap) * 0.5;
}
} else {
gap = foot_y - cy;
if (foot_y - cy <= basic_length) {
cy = cy - (basic_length - gap) * 0.5;
foot_y = foot_y + (basic_length - gap) * 0.5;
}
}
double body_left = cx;
if (cx > foot_x) {
body_left = foot_x;
}
double body_right = cx;
if (cx < foot_x) {
body_right = foot_x;
}
double body_top = cy;
if (cy > foot_y) {
body_top = foot_y;
}
double body_bottom = cy;
if (cy < foot_y) {
body_bottom = foot_y;
}
//得到小图顶点在大图中的坐标
if (body_left < 0) {
body_left = 0;
}
if (body_top < 0) {
body_top = 0;
}
if (body_right > image_w - 1) {
body_right = image_w - 1;
}
if (body_bottom > image_h - 1) {
body_bottom = image_h - 1;
}
double _cx = feature.getFace_roi().get(0).getX();
double _cy = feature.getFace_roi().get(0).getY();
double _foot_x = feature.getFace_roi().get(0).getW();
double _foot_y = feature.getFace_roi().get(0).getH();
Integer head_x_inSmall = 0;
Integer head_y_inSmall = 0;
Integer foot_x_inSmall = 0;
Integer foot_y_inSmall = 0;
// 计算头脚在小图中的坐标
if (img_type != 9999) {
//顺时针旋转90度
if (quadrant == 3) {
zero_point[0] = body_left;
zero_point[1] = body_bottom;
head_x_inSmall = new Double(Math.abs(zero_point[1] - _cy)).intValue();
head_y_inSmall = new Double(Math.abs(zero_point[0] - _cx)).intValue();
foot_x_inSmall = new Double(Math.abs(zero_point[1] - _foot_y)).intValue();
foot_y_inSmall = new Double(Math.abs(zero_point[0] - _foot_x)).intValue();
}
//顺时针旋转180度
else if (quadrant == 2) {
zero_point[0] = body_right;
zero_point[1] = body_bottom;
head_x_inSmall = new Double(Math.abs(zero_point[0] - _cx)).intValue();
head_y_inSmall = new Double(Math.abs(zero_point[1] - _cy)).intValue();
foot_x_inSmall = new Double(Math.abs(zero_point[0] - _foot_x)).intValue();
foot_y_inSmall = new Double(Math.abs(zero_point[1] - _foot_y)).intValue();
}
//顺时针旋转270度
else if (quadrant == 1) {
zero_point[0] = body_right;
zero_point[1] = body_top;
head_x_inSmall = new Double(Math.abs(zero_point[1] - _cy)).intValue();
head_y_inSmall = new Double(Math.abs(zero_point[0] - _cx)).intValue();
foot_x_inSmall = new Double(Math.abs(zero_point[1] - _foot_y)).intValue();
foot_y_inSmall = new Double(Math.abs(zero_point[0] - _foot_x)).intValue();
} else {
zero_point[0] = body_left;
zero_point[1] = body_top;
head_x_inSmall = new Double(Math.abs(zero_point[0] - _cx)).intValue();
head_y_inSmall = new Double(Math.abs(zero_point[1] - _cy)).intValue();
foot_x_inSmall = new Double(Math.abs(zero_point[0] - _foot_x)).intValue();
foot_y_inSmall = new Double(Math.abs(zero_point[1] - _foot_y)).intValue();
}
} else {
zero_point[0] = body_left;
zero_point[1] = body_top;
head_x_inSmall = new Double(Math.abs(zero_point[0] - _cx)).intValue();
head_y_inSmall = new Double(Math.abs(zero_point[1] - _cy)).intValue();
foot_x_inSmall = new Double(Math.abs(zero_point[0] - _foot_x)).intValue();
foot_y_inSmall = new Double(Math.abs(zero_point[1] - _foot_y)).intValue();
} }
Map<String, Integer> resultMap = new HashMap<>(4); Map<String, Integer> resultMap = new HashMap<>(4);
resultMap.put("head_x_inSmall", head_x_inSmall); resultMap.put("head_x_inSmall", head_x_inSmall);
...@@ -1214,6 +1080,7 @@ public class ReidService { ...@@ -1214,6 +1080,7 @@ public class ReidService {
resultMap.put("foot_x_inSmall", foot_x_inSmall); resultMap.put("foot_x_inSmall", foot_x_inSmall);
resultMap.put("foot_y_inSmall", foot_y_inSmall); resultMap.put("foot_y_inSmall", foot_y_inSmall);
return JsonMessageUtil.getSuccessJsonMsg(resultMap); return JsonMessageUtil.getSuccessJsonMsg(resultMap);
} catch (Exception e) { } catch (Exception e) {
log.error("获取坐标失败:{}", e.getMessage()); log.error("获取坐标失败:{}", e.getMessage());
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!