更新 concurrency/PushVideoStreamProcess.py
This commit is contained in:
parent
57de938d7c
commit
9618bbc526
|
|
@ -23,7 +23,7 @@ from util.Cv2Utils import video_conjuncing, write_or_video, write_ai_video, push
|
||||||
from util.ImageUtils import url2Array, add_water_pic
|
from util.ImageUtils import url2Array, add_water_pic
|
||||||
from util.LogUtils import init_log
|
from util.LogUtils import init_log
|
||||||
|
|
||||||
from util.PlotsUtils import draw_painting_joint, filterBox, xywh2xyxy2, draw_name_joint
|
from util.PlotsUtils import draw_painting_joint, filterBox, xywh2xyxy2, xy2xyxy, draw_name_joint, plot_one_box_auto, draw_name_ocr,draw_name_crowd
|
||||||
|
|
||||||
from util.QueUtil import get_no_block_queue, put_queue, clear_queue
|
from util.QueUtil import get_no_block_queue, put_queue, clear_queue
|
||||||
|
|
||||||
|
|
@ -50,15 +50,8 @@ class PushStreamProcess(Process):
|
||||||
# 这里放非默认逻辑的代码
|
# 这里放非默认逻辑的代码
|
||||||
self._algSwitch = False
|
self._algSwitch = False
|
||||||
|
|
||||||
|
|
||||||
print("---line53 :PushVideoStreamProcess.py---",self._algSwitch)
|
print("---line53 :PushVideoStreamProcess.py---",self._algSwitch)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def build_logo_url(self):
|
def build_logo_url(self):
|
||||||
logo = None
|
logo = None
|
||||||
if self._context["video"]["video_add_water"]:
|
if self._context["video"]["video_add_water"]:
|
||||||
|
|
@ -155,6 +148,24 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
font_config, allowedList = draw_config["font_config"], draw_config[code]["allowedList"]
|
font_config, allowedList = draw_config["font_config"], draw_config[code]["allowedList"]
|
||||||
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
|
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
|
||||||
for qs in det_result:
|
for qs in det_result:
|
||||||
|
# 自研车牌模型处理
|
||||||
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
|
cls = 0
|
||||||
|
ocrlabel, xybox = qs
|
||||||
|
box = xy2xyxy(xybox)
|
||||||
|
score = None
|
||||||
|
color = rainbows[cls]
|
||||||
|
label_array = None
|
||||||
|
rr = t.submit(draw_name_ocr, xybox, copy_frame, color, ocrlabel)
|
||||||
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
||||||
|
cls = 0
|
||||||
|
crowdlabel, points = qs
|
||||||
|
box = [(0, 0), (0, 0), (0, 0), (0, 0)]
|
||||||
|
score = None
|
||||||
|
color = rainbows[cls]
|
||||||
|
label_array = None
|
||||||
|
rr = t.submit(draw_name_crowd, points, copy_frame, color, crowdlabel)
|
||||||
|
else:
|
||||||
try: # 应对NaN情况
|
try: # 应对NaN情况
|
||||||
box, score, cls = xywh2xyxy2(qs)
|
box, score, cls = xywh2xyxy2(qs)
|
||||||
except:
|
except:
|
||||||
|
|
@ -163,9 +174,13 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
continue
|
continue
|
||||||
label_array, color = label_arrays[cls], rainbows[cls]
|
label_array, color = label_arrays[cls], rainbows[cls]
|
||||||
if ModelType.CHANNEL2_MODEL.value[1] == str(code) and cls == 2:
|
if ModelType.CHANNEL2_MODEL.value[1] == str(code) and cls == 2:
|
||||||
rr = t.submit(draw_name_joint, box, copy_frame, draw_config[code]["label_dict"], score, color, font_config, qs[6])
|
rr = t.submit(draw_name_joint, box, copy_frame,
|
||||||
|
draw_config[code]["label_dict"], score, color,
|
||||||
|
font_config, qs[6])
|
||||||
else:
|
else:
|
||||||
rr = t.submit(draw_painting_joint, box, copy_frame, label_array, score, color, font_config)
|
rr = t.submit(draw_painting_joint, box, copy_frame, label_array,
|
||||||
|
score, color, font_config)
|
||||||
|
|
||||||
thread_p.append(rr)
|
thread_p.append(rr)
|
||||||
if det_xywh.get(code) is None:
|
if det_xywh.get(code) is None:
|
||||||
det_xywh[code] = {}
|
det_xywh[code] = {}
|
||||||
|
|
@ -246,6 +261,11 @@ class OnPushStreamProcess(PushStreamProcess):
|
||||||
is_new = False
|
is_new = False
|
||||||
if q[11] == 1:
|
if q[11] == 1:
|
||||||
is_new = True
|
is_new = True
|
||||||
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
|
cls = ocrlabel
|
||||||
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
||||||
|
cls = crowdlabel
|
||||||
|
label_array = points
|
||||||
if cd is None:
|
if cd is None:
|
||||||
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
||||||
else:
|
else:
|
||||||
|
|
@ -370,8 +390,28 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
font_config, allowedList = draw_config["font_config"], draw_config[code]["allowedList"]
|
font_config, allowedList = draw_config["font_config"], draw_config[code]["allowedList"]
|
||||||
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
|
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
|
||||||
for qs in det_result:
|
for qs in det_result:
|
||||||
box, score, cls = xywh2xyxy2(qs)
|
# 自研车牌模型处理
|
||||||
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
|
cls = 0
|
||||||
|
ocrlabel, xybox = qs
|
||||||
|
box = xy2xyxy(xybox)
|
||||||
|
score = None
|
||||||
|
color = rainbows[cls]
|
||||||
|
label_array = None
|
||||||
|
label_arrays = [None]
|
||||||
|
rr = t.submit(draw_name_ocr,xybox,copy_frame,color,ocrlabel)
|
||||||
|
|
||||||
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
||||||
|
cls = 0
|
||||||
|
crowdlabel, points = qs
|
||||||
|
box = [(0,0),(0,0),(0,0),(0,0)]
|
||||||
|
score = None
|
||||||
|
color = rainbows[cls]
|
||||||
|
label_array = None
|
||||||
|
rr = t.submit(draw_name_crowd, points, copy_frame, color, crowdlabel)
|
||||||
|
|
||||||
|
else:
|
||||||
|
box, score, cls = xywh2xyxy2(qs)
|
||||||
if cls not in allowedList or score < frame_score:
|
if cls not in allowedList or score < frame_score:
|
||||||
continue
|
continue
|
||||||
label_array, color = label_arrays[cls], rainbows[cls]
|
label_array, color = label_arrays[cls], rainbows[cls]
|
||||||
|
|
@ -379,6 +419,7 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
rr = t.submit(draw_name_joint, box, copy_frame, draw_config[code]["label_dict"], score, color, font_config, qs[6])
|
rr = t.submit(draw_name_joint, box, copy_frame, draw_config[code]["label_dict"], score, color, font_config, qs[6])
|
||||||
else:
|
else:
|
||||||
rr = t.submit(draw_painting_joint, box, copy_frame, label_array, score, color, font_config)
|
rr = t.submit(draw_painting_joint, box, copy_frame, label_array, score, color, font_config)
|
||||||
|
|
||||||
thread_p.append(rr)
|
thread_p.append(rr)
|
||||||
|
|
||||||
if det_xywh.get(code) is None:
|
if det_xywh.get(code) is None:
|
||||||
|
|
@ -416,7 +457,6 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
push_stream_result = t.submit(push_video_stream, frame_merge, push_p, push_url,
|
push_stream_result = t.submit(push_video_stream, frame_merge, push_p, push_url,
|
||||||
p_push_status, request_id)
|
p_push_status, request_id)
|
||||||
|
|
||||||
|
|
||||||
if qs_np is not None:
|
if qs_np is not None:
|
||||||
if len(qs_np.shape) == 1:
|
if len(qs_np.shape) == 1:
|
||||||
qs_np = qs_np[np.newaxis,...]
|
qs_np = qs_np[np.newaxis,...]
|
||||||
|
|
@ -459,6 +499,13 @@ class OffPushStreamProcess(PushStreamProcess):
|
||||||
is_new = False
|
is_new = False
|
||||||
if q[11] == 1:
|
if q[11] == 1:
|
||||||
is_new = True
|
is_new = True
|
||||||
|
|
||||||
|
if ModelType.CITY_CARPLATE_MODEL.value[1] == str(code):
|
||||||
|
cls = ocrlabel
|
||||||
|
elif ModelType.CITY_DENSECROWDCOUNT_MODEL.value[1] == str(code):
|
||||||
|
cls = crowdlabel
|
||||||
|
label_array = points
|
||||||
|
|
||||||
if cd is None:
|
if cd is None:
|
||||||
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue