Commit e1e820ff by 朱海

[chg]红线展示修改

1 parent 62095cd9
......@@ -1046,167 +1046,33 @@ public class ReidService {
if (null == picId) {
return JsonMessageUtil.getErrorJsonMsg("picId不能为空");
}
try {
Feature feature = storageUtils.getFeatureByPic(picId);
if (null == feature) {
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 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 img_type = feature.getBody_roi().get(0).getX();
double gap = 0;
// 计算图像位置
if (cx > image_w / 2 + 420) {
quadrant = 1;
} else if (cx < image_w / 2 - 420) {
quadrant = 3;
} else if (cy > image_h / 2) {
quadrant = 2;
}
Integer bodyWidth = 80;
Integer headSize = 120;
Integer basic_length = 340;
if (img_type == 9999) {
bodyWidth = 120;
headSize = 120;
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();
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();
Integer head_x_inSmall = new Double(Math.abs(cx - lefttop_x)).intValue();
Integer head_y_inSmall = new Double(Math.abs(cy - lefttop_y)).intValue();
Integer foot_x_inSmall = new Double(Math.abs(foot_x - lefttop_x)).intValue();
Integer foot_y_inSmall = new Double(Math.abs(foot_y - lefttop_y)).intValue();
if (quadrant == 1 || quadrant == 3) {
int temp;
temp = head_x_inSmall;
head_x_inSmall = head_y_inSmall;
head_y_inSmall = temp;
temp = foot_x_inSmall;
foot_x_inSmall = foot_y_inSmall;
foot_y_inSmall = temp;
}
Map<String, Integer> resultMap = new HashMap<>(4);
resultMap.put("head_x_inSmall", head_x_inSmall);
......@@ -1214,6 +1080,7 @@ public class ReidService {
resultMap.put("foot_x_inSmall", foot_x_inSmall);
resultMap.put("foot_y_inSmall", foot_y_inSmall);
return JsonMessageUtil.getSuccessJsonMsg(resultMap);
} catch (Exception e) {
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!