提交 | 用户 | 时间
|
149dd0
|
1 |
package com.iailab.netsdk.demo.frame.TargetRecognition; |
H |
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.EventQueue; |
|
6 |
import java.awt.FlowLayout; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.event.ActionListener; |
|
9 |
import java.awt.event.WindowAdapter; |
|
10 |
import java.awt.event.WindowEvent; |
|
11 |
import java.io.IOException; |
|
12 |
import java.io.UnsupportedEncodingException; |
|
13 |
import java.util.Vector; |
|
14 |
import java.util.concurrent.ExecutionException; |
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
import javax.swing.DefaultComboBoxModel; |
|
19 |
import javax.swing.JButton; |
|
20 |
import javax.swing.JCheckBox; |
|
21 |
import javax.swing.JComboBox; |
|
22 |
import javax.swing.JDialog; |
|
23 |
import javax.swing.JLabel; |
|
24 |
import javax.swing.JOptionPane; |
|
25 |
import javax.swing.JPanel; |
|
26 |
import javax.swing.JProgressBar; |
|
27 |
import javax.swing.JScrollPane; |
|
28 |
import javax.swing.JTextArea; |
|
29 |
import javax.swing.JTextField; |
|
30 |
import javax.swing.SwingUtilities; |
|
31 |
import javax.swing.SwingWorker; |
|
32 |
|
|
33 |
import com.sun.jna.Memory; |
|
34 |
import com.sun.jna.Pointer; |
|
35 |
|
|
36 |
import com.iailab.netsdk.common.DateChooserJButtonEx; |
|
37 |
import com.iailab.netsdk.common.PaintPanel; |
|
38 |
import com.iailab.netsdk.common.Res; |
|
39 |
import com.iailab.netsdk.demo.module.LoginModule; |
|
40 |
import com.iailab.netsdk.demo.module.SearchByPictureModule; |
|
41 |
import com.iailab.netsdk.lib.NetSDKLib; |
|
42 |
import com.iailab.netsdk.lib.ToolKits; |
|
43 |
import com.iailab.netsdk.lib.NetSDKLib.*; |
|
44 |
|
|
45 |
public class SearchByPicDialog extends JDialog { |
|
46 |
/** |
|
47 |
* |
|
48 |
*/ |
|
49 |
private static final long serialVersionUID = 1L; |
|
50 |
|
|
51 |
private Vector<String> chnList = new Vector<String>(); |
|
52 |
private Memory memory = null; |
|
53 |
private static volatile int nProgress = 0; // 设备处理进度 |
|
54 |
private static volatile int nCount = 0; |
|
55 |
|
|
56 |
public SearchByPicDialog() { |
|
57 |
setTitle(Res.string().getSearchByPic()); |
|
58 |
setLayout(new BorderLayout()); |
|
59 |
setModal(true); |
|
60 |
pack(); |
|
61 |
setSize(780, 550); |
|
62 |
setResizable(false); |
|
63 |
setLocationRelativeTo(null); |
|
64 |
setDefaultCloseOperation(DISPOSE_ON_CLOSE); // 释放窗体 |
|
65 |
|
|
66 |
JPanel panel = new JPanel(); |
|
67 |
progressBar = new JProgressBar(0, 100); |
|
68 |
Dimension dimension = new Dimension(); |
|
69 |
dimension.height = 18; |
|
70 |
progressBar.setPreferredSize(dimension); |
|
71 |
progressBar.setStringPainted(true); |
|
72 |
|
|
73 |
add(panel, BorderLayout.CENTER); |
|
74 |
add(progressBar, BorderLayout.SOUTH); |
|
75 |
|
|
76 |
//////// |
|
77 |
panel.setLayout(new BorderLayout()); |
|
78 |
SearchPicConditionPanel searchPicConditionPanel = new SearchPicConditionPanel(); |
|
79 |
searchPicInfoTextArea = new JTextArea(); |
|
80 |
|
|
81 |
Dimension dimension1 = new Dimension(); |
|
82 |
dimension1.width = 220; |
|
83 |
searchPicConditionPanel.setPreferredSize(dimension1); |
|
84 |
|
|
85 |
panel.add(searchPicConditionPanel, BorderLayout.WEST); |
|
86 |
panel.add(new JScrollPane(searchPicInfoTextArea), BorderLayout.CENTER); |
|
87 |
|
|
88 |
addWindowListener(new WindowAdapter() { |
|
89 |
public void windowClosing(WindowEvent e) { |
|
90 |
dispose(); |
|
91 |
} |
|
92 |
}); |
|
93 |
} |
|
94 |
|
|
95 |
private class SearchPicConditionPanel extends JPanel { |
|
96 |
|
|
97 |
/** |
|
98 |
* |
|
99 |
*/ |
|
100 |
private static final long serialVersionUID = 1L; |
|
101 |
|
|
102 |
public SearchPicConditionPanel() { |
|
103 |
setLayout(new BorderLayout()); |
|
104 |
|
|
105 |
JPanel panelNorth = new JPanel(); |
|
106 |
JPanel panelSouth = new JPanel(); |
|
107 |
|
|
108 |
add(panelNorth, BorderLayout.NORTH); |
|
109 |
add(panelSouth, BorderLayout.SOUTH); |
|
110 |
|
|
111 |
//////// |
|
112 |
searchPicPanel = new PaintPanel(); |
|
113 |
JButton selectPicBtn = new JButton(Res.string().getSelectPicture()); |
|
114 |
JButton downloadBtn = new JButton(Res.string().getDownloadQueryPicture()); |
|
115 |
|
|
116 |
searchPicPanel.setPreferredSize(new Dimension(210, 270)); |
|
117 |
selectPicBtn.setPreferredSize(new Dimension(210, 20)); |
|
118 |
downloadBtn.setPreferredSize(new Dimension(210, 20)); |
|
119 |
|
|
120 |
panelNorth.setLayout(new FlowLayout()); |
|
121 |
panelNorth.setPreferredSize(new Dimension(210, 330)); |
|
122 |
panelNorth.add(searchPicPanel); |
|
123 |
panelNorth.add(selectPicBtn); |
|
124 |
panelNorth.add(downloadBtn); |
|
125 |
|
|
126 |
///// |
|
127 |
faceCheckBox = new JCheckBox(Res.string().getFaceLibrary()); |
|
128 |
historyCheckBox = new JCheckBox(Res.string().getHistoryLibrary()); |
|
129 |
faceCheckBox.setPreferredSize(new Dimension(100, 20)); |
|
130 |
historyCheckBox.setPreferredSize(new Dimension(100, 20)); |
|
131 |
|
|
132 |
startTimeLabel = new JLabel(Res.string().getStartTime(), JLabel.CENTER); |
|
133 |
endTimeLabel = new JLabel(Res.string().getEndTime(), JLabel.CENTER); |
|
134 |
chnLabel = new JLabel(Res.string().getChannel(), JLabel.CENTER); |
|
135 |
JLabel similaryLabel = new JLabel(Res.string().getSimilarity(), JLabel.CENTER); |
|
136 |
|
|
137 |
Dimension dimension1 = new Dimension(); |
|
138 |
dimension1.width = 80; |
|
139 |
dimension1.height = 20; |
|
140 |
|
|
141 |
startTimeLabel.setPreferredSize(dimension1); |
|
142 |
endTimeLabel.setPreferredSize(dimension1); |
|
143 |
chnLabel.setPreferredSize(dimension1); |
|
144 |
similaryLabel.setPreferredSize(dimension1); |
|
145 |
|
|
146 |
startTimeBtn = new DateChooserJButtonEx("2018-11-07"); |
|
147 |
endTimeBtn = new DateChooserJButtonEx(); |
|
148 |
|
|
149 |
chnComboBox = new JComboBox(); |
|
150 |
for(int i = 1; i < LoginModule.m_stDeviceInfo.byChanNum + 1; i++) { |
|
151 |
chnList.add(Res.string().getChannel() + " " + String.valueOf(i)); |
|
152 |
} |
|
153 |
|
|
154 |
// 登陆成功,将通道添加到控件 |
|
155 |
chnComboBox.setModel(new DefaultComboBoxModel(chnList)); |
|
156 |
|
|
157 |
similaryTextField = new JTextField("60", JTextField.CENTER); |
|
158 |
|
|
159 |
Dimension dimension2 = new Dimension(); |
|
160 |
dimension2.width = 120; |
|
161 |
dimension2.height = 20; |
|
162 |
|
|
163 |
startTimeBtn.setPreferredSize(dimension2); |
|
164 |
endTimeBtn.setPreferredSize(dimension2); |
|
165 |
chnComboBox.setPreferredSize(dimension2); |
|
166 |
similaryTextField.setPreferredSize(dimension2); |
|
167 |
|
|
168 |
searchPicBtn = new JButton(Res.string().getSearch()); |
|
169 |
searchPicBtn.setPreferredSize(new Dimension(210, 20)); |
|
170 |
|
|
171 |
panelSouth.setLayout(new FlowLayout()); |
|
172 |
panelSouth.setPreferredSize(new Dimension(210, 160)); |
|
173 |
panelSouth.add(faceCheckBox); |
|
174 |
panelSouth.add(historyCheckBox); |
|
175 |
panelSouth.add(startTimeLabel); |
|
176 |
panelSouth.add(startTimeBtn); |
|
177 |
panelSouth.add(endTimeLabel); |
|
178 |
panelSouth.add(endTimeBtn); |
|
179 |
panelSouth.add(chnLabel); |
|
180 |
panelSouth.add(chnComboBox); |
|
181 |
panelSouth.add(similaryLabel); |
|
182 |
panelSouth.add(similaryTextField); |
|
183 |
panelSouth.add(searchPicBtn); |
|
184 |
|
|
185 |
historyCheckBox.setSelected(true); |
|
186 |
faceCheckBox.setSelected(false); |
|
187 |
|
|
188 |
// 选择图片,获取图片的信息 |
|
189 |
selectPicBtn.addActionListener(new ActionListener() { |
|
190 |
@Override |
|
191 |
public void actionPerformed(ActionEvent arg0) { |
|
192 |
String picPath = ""; |
|
193 |
|
|
194 |
// 选择图片,获取图片路径,并在界面显示 |
|
195 |
picPath = ToolKits.openPictureFile(searchPicPanel); |
|
196 |
|
|
197 |
if(!picPath.equals("")) { |
|
198 |
try { |
|
199 |
memory = ToolKits.readPictureFile(picPath); |
|
200 |
} catch (IOException e) { |
|
201 |
// TODO Auto-generated catch block |
|
202 |
e.printStackTrace(); |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
} |
|
207 |
}); |
|
208 |
|
|
209 |
downloadBtn.addActionListener(new ActionListener() { |
|
210 |
@Override |
|
211 |
public void actionPerformed(ActionEvent arg0) { |
|
212 |
DownloadPictureDialog dialog = new DownloadPictureDialog(); |
|
213 |
dialog.setVisible(true); |
|
214 |
} |
|
215 |
}); |
|
216 |
|
|
217 |
searchPicBtn.addActionListener(new ActionListener() { |
|
218 |
@Override |
|
219 |
public void actionPerformed(ActionEvent arg0) { |
|
220 |
SwingUtilities.invokeLater(new Runnable() { |
|
221 |
@Override |
|
222 |
public void run() { |
|
223 |
searchPicBtn.setEnabled(false); |
|
224 |
progressBar.setValue(0); |
|
225 |
searchPicInfoTextArea.setText(""); |
|
226 |
} |
|
227 |
}); |
|
228 |
|
|
229 |
searchByPicture(); |
|
230 |
} |
|
231 |
}); |
|
232 |
|
|
233 |
faceCheckBox.addActionListener(new ActionListener() { |
|
234 |
@Override |
|
235 |
public void actionPerformed(ActionEvent arg0) { |
|
236 |
if(faceCheckBox.isSelected()) { |
|
237 |
historyCheckBox.setSelected(false); |
|
238 |
chnLabel.setVisible(false); |
|
239 |
chnComboBox.setVisible(false); |
|
240 |
startTimeLabel.setVisible(false); |
|
241 |
endTimeLabel.setVisible(false); |
|
242 |
startTimeBtn.setVisible(false); |
|
243 |
endTimeBtn.setVisible(false); |
|
244 |
} else { |
|
245 |
historyCheckBox.setSelected(true); |
|
246 |
chnLabel.setVisible(true); |
|
247 |
chnComboBox.setVisible(true); |
|
248 |
startTimeLabel.setVisible(true); |
|
249 |
endTimeLabel.setVisible(true); |
|
250 |
startTimeBtn.setVisible(true); |
|
251 |
endTimeBtn.setVisible(true); |
|
252 |
} |
|
253 |
} |
|
254 |
}); |
|
255 |
|
|
256 |
historyCheckBox.addActionListener(new ActionListener() { |
|
257 |
@Override |
|
258 |
public void actionPerformed(ActionEvent arg0) { |
|
259 |
if(historyCheckBox.isSelected()) { |
|
260 |
faceCheckBox.setSelected(false); |
|
261 |
chnLabel.setVisible(true); |
|
262 |
chnComboBox.setVisible(true); |
|
263 |
startTimeLabel.setVisible(true); |
|
264 |
endTimeLabel.setVisible(true); |
|
265 |
startTimeBtn.setVisible(true); |
|
266 |
endTimeBtn.setVisible(true); |
|
267 |
} else { |
|
268 |
faceCheckBox.setSelected(true); |
|
269 |
chnLabel.setVisible(false); |
|
270 |
chnComboBox.setVisible(false); |
|
271 |
startTimeLabel.setVisible(false); |
|
272 |
endTimeLabel.setVisible(false); |
|
273 |
startTimeBtn.setVisible(false); |
|
274 |
endTimeBtn.setVisible(false); |
|
275 |
} |
|
276 |
} |
|
277 |
}); |
|
278 |
} |
|
279 |
} |
|
280 |
|
|
281 |
private void searchByPicture() { |
|
282 |
new SwingWorker<Boolean, StringBuffer>() { |
|
283 |
int nTotalCount = 0; // 查询到的总个数 |
|
284 |
|
|
285 |
@Override |
|
286 |
protected Boolean doInBackground() { |
|
287 |
int beginNum = 0; // 偏移量 |
|
288 |
int nCount = 0; // 循环查询了几次 |
|
289 |
int index = 0; // index + 1 为查询到的总个数 |
|
290 |
int nFindCount = 10; // 每次查询的个数 |
|
291 |
|
|
292 |
StringBuffer message = null; |
|
293 |
|
|
294 |
if(memory == null) { |
|
295 |
JOptionPane.showMessageDialog(null, Res.string().getChooseFacePic(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); |
|
296 |
return false; |
|
297 |
} |
|
298 |
|
|
299 |
// 获取查询句柄 |
|
300 |
nTotalCount = SearchByPictureModule.startFindPerson(memory, |
|
301 |
startTimeBtn.getText(), |
|
302 |
endTimeBtn.getText(), |
|
303 |
historyCheckBox.isSelected(), |
|
304 |
chnComboBox.getSelectedIndex(), |
|
305 |
similaryTextField.getText()); |
|
306 |
if(nTotalCount == 0) { // 查询失败 |
|
307 |
// 查询失败,关闭查询 |
|
308 |
SearchByPictureModule.doFindClosePerson(); |
|
309 |
return false; |
|
310 |
} else if(nTotalCount == -1) { // 设备正在处理,通过订阅来查询处理进度 |
|
311 |
nProgress = 0; |
|
312 |
nCount = 0; |
|
313 |
SearchByPictureModule.attachFaceFindState(fFaceFindStateCb.getInstance()); |
|
314 |
} else { |
|
315 |
while(true) { |
|
316 |
CANDIDATE_INFOEX[] caInfoexs = SearchByPictureModule.doFindNextPerson(beginNum, nFindCount); |
|
317 |
if(caInfoexs == null) { |
|
318 |
break; |
|
319 |
} |
|
320 |
|
|
321 |
for(int i = 0; i < caInfoexs.length; i++) { |
|
322 |
index = i + nFindCount * nCount + 1; |
|
323 |
|
|
324 |
// 清空 |
|
325 |
message = new StringBuffer(); |
|
326 |
|
|
327 |
if(historyCheckBox.isSelected()) { // 历史库显示 |
|
328 |
message.append("[" + index + "]"+Res.string().getTime()+":" + caInfoexs[i].stTime.toStringTimeEx() + "\n"); |
|
329 |
|
|
330 |
message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n"); |
|
331 |
message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n"); |
|
332 |
message.append("[" + index + "]"+Res.string().getAge()+":" + caInfoexs[i].stPersonInfo.byAge + "\n"); |
|
333 |
message.append("[" + index + "]"+Res.string().getColor()+":" + Res.string().getColor(0) + "\n"); |
|
334 |
message.append("[" + index + "]"+Res.string().getEye()+":" + Res.string().getEyeState(caInfoexs[i].stPersonInfo.emEye) + "\n"); |
|
335 |
message.append("[" + index + "]"+Res.string().getMouth()+":" + Res.string().getMouthState(caInfoexs[i].stPersonInfo.emMouth) + "\n"); |
|
336 |
message.append("[" + index + "]"+Res.string().getMask()+":" + Res.string().getMaskState(caInfoexs[i].stPersonInfo.emMask) + "\n"); |
|
337 |
message.append("[" + index + "]"+Res.string().getBeard()+":" + Res.string().getBeardState(caInfoexs[i].stPersonInfo.emBeard) + "\n"); |
|
338 |
message.append("[" + index + "]"+Res.string().getGlasses()+":" + Res.string().getGlasses(caInfoexs[i].stPersonInfo.byGlasses) + "\n"); |
|
339 |
message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n"); |
|
340 |
message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n"); |
|
341 |
|
|
342 |
} else { // 人脸库显示 |
|
343 |
message.append("[" + index + "]"+Res.string().getFaceLibraryID()+":" + new String(caInfoexs[i].stPersonInfo.szGroupID).trim() + "\n"); |
|
344 |
try { |
|
345 |
message.append("[" + index + "]"+Res.string().getFaceLibraryName()+":" + new String(caInfoexs[i].stPersonInfo.szGroupName, "GBK").trim() + "\n"); |
|
346 |
message.append("[" + index + "]"+Res.string().getName()+":" + new String(caInfoexs[i].stPersonInfo.szPersonName, "GBK").trim() + "\n"); |
|
347 |
} catch (UnsupportedEncodingException e) { |
|
348 |
e.printStackTrace(); |
|
349 |
} |
|
350 |
message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n"); |
|
351 |
message.append("[" + index + "]"+Res.string().getBirthday()+":" + (caInfoexs[i].stPersonInfo.wYear) + "-" + |
|
352 |
(0xff & caInfoexs[i].stPersonInfo.byMonth) + "-" + |
|
353 |
(0xff & caInfoexs[i].stPersonInfo.byDay) + "\n"); |
|
354 |
message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n"); |
|
355 |
message.append("[" + index + "]"+Res.string().getCardType()+":" + Res.string().getIdType(caInfoexs[i].stPersonInfo.byIDType) + "\n"); |
|
356 |
message.append("[" + index + "]"+Res.string().getCardNum()+":" + new String(caInfoexs[i].stPersonInfo.szID).trim() + "\n"); |
|
357 |
message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n"); |
|
358 |
message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n"); |
|
359 |
} |
|
360 |
|
|
361 |
message.append("\n"); |
|
362 |
publish(message); |
|
363 |
} |
|
364 |
|
|
365 |
if(caInfoexs.length < nFindCount) { |
|
366 |
System.out.printf("No More Record, Find End!\n"); |
|
367 |
break; |
|
368 |
} else { |
|
369 |
beginNum += nFindCount; |
|
370 |
nCount++; |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
374 |
// 关闭查询 |
|
375 |
SearchByPictureModule.doFindClosePerson(); |
|
376 |
} |
|
377 |
|
|
378 |
return true; |
|
379 |
} |
|
380 |
|
|
381 |
@Override |
|
382 |
protected void process(java.util.List<StringBuffer> chunks) { |
|
383 |
for(StringBuffer data : chunks) { |
|
384 |
searchPicInfoTextArea.append(data.toString()); |
|
385 |
searchPicInfoTextArea.updateUI(); |
|
386 |
} |
|
387 |
|
|
388 |
super.process(chunks); |
|
389 |
} |
|
390 |
|
|
391 |
@Override |
|
392 |
protected void done() { |
|
393 |
if(nTotalCount == 0) { // 查询总个数失败 |
|
394 |
searchPicBtn.setEnabled(true); |
|
395 |
progressBar.setValue(100); |
|
396 |
searchPicInfoTextArea.append("未查询到相关信息... \n"); |
|
397 |
searchPicInfoTextArea.updateUI(); |
|
398 |
} else if(nTotalCount == -1){ // 设备在处理中 |
|
399 |
searchPicInfoTextArea.append(Res.string().getLoading()+"... \n"); |
|
400 |
searchPicInfoTextArea.updateUI(); |
|
401 |
} else { |
|
402 |
try { |
|
403 |
if(get()) { // 其他情况,查询信息结束 |
|
404 |
searchPicBtn.setEnabled(true); |
|
405 |
progressBar.setValue(100); |
|
406 |
searchPicInfoTextArea.append("查询结束... \n"); |
|
407 |
searchPicInfoTextArea.updateUI(); |
|
408 |
} |
|
409 |
} catch (InterruptedException e) { |
|
410 |
e.printStackTrace(); |
|
411 |
} catch (ExecutionException e) { |
|
412 |
e.printStackTrace(); |
|
413 |
} |
|
414 |
} |
|
415 |
} |
|
416 |
}.execute(); |
|
417 |
} |
|
418 |
|
|
419 |
/** |
|
420 |
* 订阅人脸回调函数 |
|
421 |
*/ |
|
422 |
private static class fFaceFindStateCb implements NetSDKLib.fFaceFindState { |
|
423 |
private fFaceFindStateCb() {} |
|
424 |
|
|
425 |
private static class fFaceFindStateCbHolder { |
|
426 |
private static final fFaceFindStateCb instance = new fFaceFindStateCb(); |
|
427 |
} |
|
428 |
|
|
429 |
public static fFaceFindStateCb getInstance() { |
|
430 |
return fFaceFindStateCbHolder.instance; |
|
431 |
} |
|
432 |
|
|
433 |
@Override |
|
434 |
public void invoke(LLong lLoginID, LLong lAttachHandle, |
|
435 |
Pointer pstStates, int nStateNum, Pointer dwUser) { |
|
436 |
if(nStateNum < 1) { |
|
437 |
return; |
|
438 |
} |
|
439 |
NET_CB_FACE_FIND_STATE[] msg = new NET_CB_FACE_FIND_STATE[nStateNum]; |
|
440 |
for(int i = 0; i < nStateNum; i++) { |
|
441 |
msg[i] = new NET_CB_FACE_FIND_STATE(); |
|
442 |
} |
|
443 |
ToolKits.GetPointerDataToStructArr(pstStates, msg); |
|
444 |
|
|
445 |
for(int i = 0; i < nStateNum; i++) { |
|
446 |
if(SearchByPictureModule.nToken == msg[i].nToken) { |
|
447 |
nProgress = msg[i].nProgress; |
|
448 |
nCount = msg[i].nCurrentCount; // 返回的总个数 |
|
449 |
|
|
450 |
// 刷新设备处理进度 |
|
451 |
// UI线程 |
|
452 |
EventQueue.invokeLater(new Runnable() { |
|
453 |
@Override |
|
454 |
public void run() { |
|
455 |
progressBar.setValue(nProgress); |
|
456 |
|
|
457 |
if(nProgress == 100) { // 进度等于100,设备处理完毕,开始查询 |
|
458 |
// 异步线程处理 |
|
459 |
new SearchPictureWoker(nCount).execute(); |
|
460 |
} |
|
461 |
} |
|
462 |
}); |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
/** |
|
469 |
* 用于订阅人脸状态后的查询 |
|
470 |
* 以图搜图与查询人员信息的接口是一样的,只是逻辑不一样,doFindNextPerson接口时,都是指定每次查询的个数,最大20,然后根据偏移量循环查询 |
|
471 |
* SwingWorker为异步线程,回调属于子线程,不能做耗时操作和刷新UI |
|
472 |
*/ |
|
473 |
private static class SearchPictureWoker extends SwingWorker<Boolean, StringBuffer> { |
|
474 |
private int nTotalCount; // 查询到的总个数 |
|
475 |
public SearchPictureWoker(int nTotalCount) { |
|
476 |
this.nTotalCount = nTotalCount; |
|
477 |
} |
|
478 |
|
|
479 |
@Override |
|
480 |
protected Boolean doInBackground() { |
|
481 |
int beginNum = 0; // 偏移量 |
|
482 |
int nCount = 0; // 循环查询了几次 |
|
483 |
int index = 0; // index + 1 为查询到的总个数 |
|
484 |
int nFindCount = 10; // 每次查询的个数 |
|
485 |
|
|
486 |
StringBuffer message = null; |
|
487 |
|
|
488 |
// 进度达到100%,关闭订阅 |
|
489 |
SearchByPictureModule.detachFaceFindState(); |
|
490 |
System.out.println("nTotalCount = " + nTotalCount); |
|
491 |
if(nTotalCount == 0) { |
|
492 |
// 关闭查询 |
|
493 |
SearchByPictureModule.doFindClosePerson(); |
|
494 |
return false; |
|
495 |
} |
|
496 |
|
|
497 |
while(true) { |
|
498 |
CANDIDATE_INFOEX[] caInfoexs = SearchByPictureModule.doFindNextPerson(beginNum, nFindCount); |
|
499 |
if(caInfoexs == null) { |
|
500 |
break; |
|
501 |
} |
|
502 |
|
|
503 |
for(int i = 0; i < caInfoexs.length; i++) { |
|
504 |
index = i + nFindCount * nCount + 1; |
|
505 |
|
|
506 |
// 清空 |
|
507 |
message = new StringBuffer(); |
|
508 |
|
|
509 |
if(historyCheckBox.isSelected()) { // 历史库显示 |
|
510 |
message.append("[" + index + "]"+Res.string().getTime()+":" + caInfoexs[i].stTime.toStringTimeEx() + "\n"); |
|
511 |
|
|
512 |
message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n"); |
|
513 |
message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n"); |
|
514 |
message.append("[" + index + "]"+Res.string().getAge()+":" + caInfoexs[i].stPersonInfo.byAge + "\n"); |
|
515 |
message.append("[" + index + "]"+Res.string().getColor()+":" + Res.string().getColor(0) + "\n"); |
|
516 |
message.append("[" + index + "]"+Res.string().getEye()+":" + Res.string().getEyeState(caInfoexs[i].stPersonInfo.emEye) + "\n"); |
|
517 |
message.append("[" + index + "]"+Res.string().getMouth()+":" + Res.string().getMouthState(caInfoexs[i].stPersonInfo.emMouth) + "\n"); |
|
518 |
message.append("[" + index + "]"+Res.string().getMask()+":" + Res.string().getMaskState(caInfoexs[i].stPersonInfo.emMask) + "\n"); |
|
519 |
message.append("[" + index + "]"+Res.string().getBeard()+":" + Res.string().getBeardState(caInfoexs[i].stPersonInfo.emBeard) + "\n"); |
|
520 |
message.append("[" + index + "]"+Res.string().getGlasses()+":" + Res.string().getGlasses(caInfoexs[i].stPersonInfo.byGlasses) + "\n"); |
|
521 |
message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n"); |
|
522 |
message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n"); |
|
523 |
|
|
524 |
} else { // 人脸库显示 |
|
525 |
message.append("[" + index + "]"+Res.string().getFaceLibraryID()+":" + new String(caInfoexs[i].stPersonInfo.szGroupID).trim() + "\n"); |
|
526 |
try { |
|
527 |
message.append("[" + index + "]"+Res.string().getFaceLibraryName()+":" + new String(caInfoexs[i].stPersonInfo.szGroupName, "GBK").trim() + "\n"); |
|
528 |
message.append("[" + index + "]"+Res.string().getName()+":" + new String(caInfoexs[i].stPersonInfo.szPersonName, "GBK").trim() + "\n"); |
|
529 |
} catch (UnsupportedEncodingException e) { |
|
530 |
e.printStackTrace(); |
|
531 |
} |
|
532 |
message.append("[" + index + "]"+Res.string().getUid()+":" + new String(caInfoexs[i].stPersonInfo.szUID).trim() + "\n"); |
|
533 |
message.append("[" + index + "]"+Res.string().getBirthday()+":" + (caInfoexs[i].stPersonInfo.wYear) + "-" + |
|
534 |
(0xff & caInfoexs[i].stPersonInfo.byMonth) + "-" + |
|
535 |
(0xff & caInfoexs[i].stPersonInfo.byDay) + "\n"); |
|
536 |
message.append("[" + index + "]"+Res.string().getSex()+":" + Res.string().getSex(caInfoexs[i].stPersonInfo.bySex) + "\n"); |
|
537 |
message.append("[" + index + "]"+Res.string().getCardType()+":" + Res.string().getIdType(caInfoexs[i].stPersonInfo.byIDType) + "\n"); |
|
538 |
message.append("[" + index + "]"+Res.string().getCardNum()+":" + new String(caInfoexs[i].stPersonInfo.szID).trim() + "\n"); |
|
539 |
message.append("[" + index + "]"+Res.string().getSimilarity()+":" + caInfoexs[i].bySimilarity + "\n"); |
|
540 |
message.append("[" + index + "]"+Res.string().getPicturePath()+":" + caInfoexs[i].stPersonInfo.szFacePicInfo[0].pszFilePath.getString(0) + "\n"); |
|
541 |
} |
|
542 |
|
|
543 |
message.append("\n"); |
|
544 |
publish(message); |
|
545 |
} |
|
546 |
|
|
547 |
if(caInfoexs.length < nFindCount) { |
|
548 |
System.out.printf("No More Record, Find End!\n"); |
|
549 |
break; |
|
550 |
} else { |
|
551 |
beginNum += nFindCount; |
|
552 |
nCount++; |
|
553 |
} |
|
554 |
} |
|
555 |
|
|
556 |
// 关闭查询 |
|
557 |
SearchByPictureModule.doFindClosePerson(); |
|
558 |
|
|
559 |
return true; |
|
560 |
} |
|
561 |
|
|
562 |
@Override |
|
563 |
protected void process(java.util.List<StringBuffer> chunks) { |
|
564 |
for(StringBuffer data : chunks) { |
|
565 |
searchPicInfoTextArea.append(data.toString()); |
|
566 |
searchPicInfoTextArea.updateUI(); |
|
567 |
} |
|
568 |
|
|
569 |
super.process(chunks); |
|
570 |
} |
|
571 |
|
|
572 |
@Override |
|
573 |
protected void done() { |
|
574 |
searchPicBtn.setEnabled(true); |
|
575 |
searchPicInfoTextArea.append(Res.string().getEndSearch()+"... \n"); |
|
576 |
searchPicInfoTextArea.updateUI(); |
|
577 |
} |
|
578 |
} |
|
579 |
|
|
580 |
|
|
581 |
private static JTextArea searchPicInfoTextArea; |
|
582 |
private static JProgressBar progressBar; |
|
583 |
private static JButton searchPicBtn; |
|
584 |
|
|
585 |
private PaintPanel searchPicPanel; |
|
586 |
private JComboBox chnComboBox; |
|
587 |
private JTextField similaryTextField; |
|
588 |
private DateChooserJButtonEx startTimeBtn; |
|
589 |
private DateChooserJButtonEx endTimeBtn; |
|
590 |
private JLabel chnLabel; |
|
591 |
private JLabel startTimeLabel; |
|
592 |
private JLabel endTimeLabel; |
|
593 |
|
|
594 |
private JCheckBox faceCheckBox; |
|
595 |
private static JCheckBox historyCheckBox; |
|
596 |
} |