未验证 提交 16a657e5 编写于 作者: Z zhiboniu 提交者: GitHub

car licenseplate skipframe&time counter vote (#6609)

* car licenseplate skipframe&time counter vote

* incase of no track
上级 d1892fff
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
import os import os
import copy import copy
from collections import Counter
class Result(object): class Result(object):
...@@ -113,9 +114,18 @@ class DataCollector(object): ...@@ -113,9 +114,18 @@ class DataCollector(object):
idx]) idx])
self.collector[ids]["qualities"].append(reid_res['qualities'][ self.collector[ids]["qualities"].append(reid_res['qualities'][
idx]) idx])
if vehicleplate_res: if vehicleplate_res and vehicleplate_res['plate'][idx] != "":
self.collector[ids]["vehicleplate"].append(vehicleplate_res[ self.collector[ids]["vehicleplate"].append(vehicleplate_res[
'plate'][idx]) 'plate'][idx])
def get_res(self): def get_res(self):
return self.collector return self.collector
def get_carlp(self, trackid):
lps = self.collector[trackid]["vehicleplate"]
counter = Counter(lps)
carlp = counter.most_common()
if len(carlp) > 0:
return carlp[0][0]
else:
return None
...@@ -781,7 +781,7 @@ class PipePredictor(object): ...@@ -781,7 +781,7 @@ class PipePredictor(object):
crop_input, new_bboxes, ori_bboxes = crop_image_with_mot( crop_input, new_bboxes, ori_bboxes = crop_image_with_mot(
frame_rgb, mot_res) frame_rgb, mot_res)
if self.with_vehicleplate: if self.with_vehicleplate and frame_id % 10 == 0:
if frame_id > self.warmup_frame: if frame_id > self.warmup_frame:
self.pipe_timer.module_time['vehicleplate'].start() self.pipe_timer.module_time['vehicleplate'].start()
plate_input, _, _ = crop_image_with_mot( plate_input, _, _ = crop_image_with_mot(
...@@ -791,6 +791,8 @@ class PipePredictor(object): ...@@ -791,6 +791,8 @@ class PipePredictor(object):
if frame_id > self.warmup_frame: if frame_id > self.warmup_frame:
self.pipe_timer.module_time['vehicleplate'].end() self.pipe_timer.module_time['vehicleplate'].end()
self.pipeline_res.update(platelicense, 'vehicleplate') self.pipeline_res.update(platelicense, 'vehicleplate')
else:
self.pipeline_res.clear('vehicleplate')
if self.with_human_attr: if self.with_human_attr:
if frame_id > self.warmup_frame: if frame_id > self.warmup_frame:
...@@ -935,9 +937,9 @@ class PipePredictor(object): ...@@ -935,9 +937,9 @@ class PipePredictor(object):
if self.cfg['visual']: if self.cfg['visual']:
_, _, fps = self.pipe_timer.get_total_time() _, _, fps = self.pipe_timer.get_total_time()
im = self.visualize_video(frame, self.pipeline_res, frame_id, im = self.visualize_video(
fps, entrance, records, frame, self.pipeline_res, self.collector, frame_id, fps,
center_traj) # visualize entrance, records, center_traj) # visualize
writer.write(im) writer.write(im)
if self.file_name is None: # use camera_id if self.file_name is None: # use camera_id
cv2.imshow('Paddle-Pipeline', im) cv2.imshow('Paddle-Pipeline', im)
...@@ -950,6 +952,7 @@ class PipePredictor(object): ...@@ -950,6 +952,7 @@ class PipePredictor(object):
def visualize_video(self, def visualize_video(self,
image, image,
result, result,
collector,
frame_id, frame_id,
fps, fps,
entrance=None, entrance=None,
...@@ -1006,11 +1009,19 @@ class PipePredictor(object): ...@@ -1006,11 +1009,19 @@ class PipePredictor(object):
image = visualize_attr(image, vehicle_attr_res, boxes) image = visualize_attr(image, vehicle_attr_res, boxes)
image = np.array(image) image = np.array(image)
vehicleplate_res = result.get('vehicleplate') if mot_res is not None:
if vehicleplate_res: vehicleplate = False
plates = []
for trackid in mot_res['boxes'][:, 0]:
plate = collector.get_carlp(trackid)
if plate != None:
vehicleplate = True
plates.append(plate)
else:
plates.append("")
if vehicleplate:
boxes = mot_res['boxes'][:, 1:] boxes = mot_res['boxes'][:, 1:]
image = visualize_vehicleplate(image, vehicleplate_res['plate'], image = visualize_vehicleplate(image, plates, boxes)
boxes)
image = np.array(image) image = np.array(image)
kpt_res = result.get('kpt') kpt_res = result.get('kpt')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册