c83b5b39
Liu Haoyu
项目创建, 集成spring-se...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
package com.objecteye.utils;
import com.objecteye.pojo.SearchDataFromRetrieveDb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
@Component
public class VehicleEngine {
@Autowired
private RestTemplate restTemplate;
@Value("${requestBase64}")
private String requestBase64;
@Value("${requestPath}")
private String requestPath;
@Value("${humanVehicleBase64}")
private String humanVehicleBase64;
@Value("${extractFeatureByBase64}")
private String extractFeatureByBase64;
@Value("${searchDataFromRetrieveDbPath}")
private String searchDataFromRetrieveDbPath;
@Value("${addUrlToDeployDb}")
private String addUrlToDeployDb;
@Value("${searchDataFromDeployDb}")
private String searchDataFromDeployDb;
@Value("${deleteDataFromDeployDb}")
private String deleteDataFromDeployDb;
private final Logger logger = LoggerFactory.getLogger(VehicleEngine.class);
/**
* 通过base64获取 车辆结构化数据信息
*
* @param tpxx base64参数信息
* @return 车辆结构化数据信息
*/
public String getVehicleInfoByBase64(String tpxx) {
return getInfoByBase64(tpxx, requestBase64);
}
/**
* 通过base64获取到人车的信息
*
* @param tpxx base64参数信息
* @return 人车结构化数据
*/
public String getHumanVehicleInfoByBase64(String tpxx) {
return getInfoByBase64(tpxx, humanVehicleBase64);
}
/**
* 根据参数获取指定uri的返回值 body体
*
* @param tpxx 请求参数
* @param uri 请求地址
* @return 返回信息body体
*/
public String getInfoByBase64(String tpxx, String uri) {
Map<String, String> uriVariables = new HashMap<>(16);
String body = null;
if (tpxx != null && tpxx.length() > 0) {
uriVariables.put("TPXX", tpxx);
ResponseEntity<String> responseEntity = null;
try {
responseEntity = restTemplate.postForEntity(uri, uriVariables, String.class);
body = responseEntity.getBody();
} catch (RestClientException e) {
e.printStackTrace();
}
}
return body;
}
/**
* 获取人脸底库对比数据
*
* @param topN 选取数据量(可能不足)
* @param threshold 设定阈值
* @param threadNum 检索线程个数
* @param feature 特征值数组
* @return 符合要求的人脸对比数据
*/
public SearchDataFromRetrieveDb searchDataFromRetrieveDb(int topN, float threshold, int threadNum, float[] feature) {
Map<String, Object> uriVariables = new HashMap<>(16);
SearchDataFromRetrieveDb body = null;
if (feature != null && feature.length > 0) {
uriVariables.put("topN", topN);
uriVariables.put("threshold", threshold);
uriVariables.put("threadNum", threadNum);
uriVariables.put("feature", feature);
ResponseEntity<SearchDataFromRetrieveDb> responseEntity = null;
try {
responseEntity = restTemplate.postForEntity(searchDataFromRetrieveDbPath, uriVariables, SearchDataFromRetrieveDb.class);
body = responseEntity.getBody();
} catch (RestClientException e) {
logger.error("您输入的图片因路径或其他原因导致无法出现识别,请将图片放入到http://192.168.10.4:8084/home/lxu/vehicleImages/new_wfcl/路径下");
}
}
return body;
}
/**
* 通过base64获取到人像数据
*
* @param base64 base64数据
* @return 获取人脸特征值数据
*/
public String getPeopleInfoByBase64(String base64) {
return getInfoByBase64(base64, extractFeatureByBase64);
}
/**
* 根据参数获取人像底库数据
*
* @param map 请求参数
* @return 人像底库满足条件的数据
*/
public String searchDataFromDeployDb(Map<String, Object> map) {
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(map);
ResponseEntity<String> response = restTemplate.postForEntity(searchDataFromDeployDb, requestEntity, String.class);
return response.getBody();
}
/**
* 根据url添加到布控库
*
* @param map
* @return
*/
public String addUrlToDeployDb(Map<String, Object> map) {
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<Map<String, Object>>(map);
ResponseEntity<String> response = restTemplate.postForEntity(addUrlToDeployDb, requestEntity, String.class);
return response.getBody();
}
/**
* 删除库中的数据
*
* @param map
* @return
*/
public String deleteDataFromDeployDb(Map<String, Object> map) {
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<Map<String, Object>>(map);
ResponseEntity<String> response = restTemplate.postForEntity(deleteDataFromDeployDb, requestEntity, String.class);
return response.getBody();
}
}
|