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