Browse Source

1报出新问题时同时绘制出其他问题;2新问题会以置信度分数为黑色字体显示,其他为白色

develop
YAO 1 year ago
parent
commit
af81423fd5
5 changed files with 64 additions and 43 deletions
  1. +1
    -1
      concurrency/FileUploadThread.py
  2. +54
    -36
      concurrency/PushVideoStreamProcess.py
  3. +2
    -2
      enums/ModelTypeEnum.py
  4. +2
    -2
      enums/ModelTypeEnum2.py
  5. +5
    -2
      util/PlotsUtils.py

+ 1
- 1
concurrency/FileUploadThread.py View File

if len(target_list) > 0: if len(target_list) > 0:
aFrame = frame.copy() aFrame = frame.copy()
for target in target_list: for target in target_list:
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config)
draw_painting_joint(target[1], aFrame, target[3], target[2], target[4], font_config, target[4])
model_info.append({"modelCode": str(code), "detectTargetCode": str(cls), "aFrame": aFrame}) model_info.append({"modelCode": str(code), "detectTargetCode": str(cls), "aFrame": aFrame})
if len(model_info) > 0: if len(model_info) > 0:
image_result = { image_result = {

+ 54
- 36
concurrency/PushVideoStreamProcess.py View File

qs_np_tmp = np.append(qs_np_tmp,qs_np_id,axis=0) qs_np_tmp = np.append(qs_np_tmp,qs_np_id,axis=0)
qs_np_tmp[:, 11] += 1 qs_np_tmp[:, 11] += 1
qs_np_tmp = np.delete(qs_np_tmp, np.where((qs_np_tmp[:, 11] >= 75))[0], axis=0) qs_np_tmp = np.delete(qs_np_tmp, np.where((qs_np_tmp[:, 11] >= 75))[0], axis=0)
for q in qs_reurn:
if q[11] == 0:
cls = int(q[9])
code = str(int(q[10])).zfill(3)
if det_xywh2.get(code) is None:
det_xywh2[code] = {}
cd = det_xywh2[code].get(cls)
score = q[8]
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
label_array, color = label_arrays[cls], rainbows[cls]
box = [(int(q[0]), int(q[1])), (int(q[2]), int(q[3])),
(int(q[4]), int(q[5])), (int(q[6]), int(q[7]))]
if cd is None:
det_xywh2[code][cls] = [[cls, box, score, label_array, color]]
else:
det_xywh2[code][cls].append([cls, box, score, label_array, color])
if len(det_xywh2) > 0:
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
has = False
for j in qs_reurn:
if j[11] == 0:
has = True
break
if has:
for q in qs_reurn:
if q[11] == 0:
cls = int(q[9])
code = str(int(q[10])).zfill(3)
if det_xywh2.get(code) is None:
det_xywh2[code] = {}
cd = det_xywh2[code].get(cls)
score = q[8]
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
label_array, color = label_arrays[cls], rainbows[cls]
box = [(int(q[0]), int(q[1])), (int(q[2]), int(q[3])),
(int(q[4]), int(q[5])), (int(q[6]), int(q[7]))]
is_new = False
if q[11] == 0:
is_new = True
if cd is None:
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
else:
det_xywh2[code][cls].append([cls, box, score, label_array, color, is_new])
if len(det_xywh2) > 0:
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))


push_p = push_stream_result.result(timeout=60) push_p = push_stream_result.result(timeout=60)
ai_video_file = write_ai_video_result.result(timeout=60) ai_video_file = write_ai_video_result.result(timeout=60)
qs_np_tmp = np.append(qs_np_tmp,qs_np_id,axis=0) qs_np_tmp = np.append(qs_np_tmp,qs_np_id,axis=0)
qs_np_tmp[:, 11] += 1 qs_np_tmp[:, 11] += 1
qs_np_tmp = np.delete(qs_np_tmp, np.where((qs_np_tmp[:, 11] >= 75))[0], axis=0) qs_np_tmp = np.delete(qs_np_tmp, np.where((qs_np_tmp[:, 11] >= 75))[0], axis=0)
for q in qs_reurn:
if q[11] == 0:
cls = int(q[9])
code = str(int(q[10])).zfill(3)
if det_xywh2.get(code) is None:
det_xywh2[code] = {}
cd = det_xywh2[code].get(cls)
score = q[8]
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
label_array, color = label_arrays[cls], rainbows[cls]
box = [(int(q[0]), int(q[1])), (int(q[2]), int(q[3])),
(int(q[4]), int(q[5])), (int(q[6]), int(q[7]))]
if cd is None:
det_xywh2[code][cls] = [[cls, box, score, label_array, color]]
else:
det_xywh2[code][cls].append([cls, box, score, label_array, color])
if len(det_xywh2) > 0:
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
has = False
for j in qs_reurn:
if j[11] == 0:
has = True
break
if has:
for q in qs_reurn:
if q[11] == 0:
cls = int(q[9])
code = str(int(q[10])).zfill(3)
if det_xywh2.get(code) is None:
det_xywh2[code] = {}
cd = det_xywh2[code].get(cls)
score = q[8]
rainbows, label_arrays = draw_config[code]["rainbows"], draw_config[code]["label_arrays"]
label_array, color = label_arrays[cls], rainbows[cls]
box = [(int(q[0]), int(q[1])), (int(q[2]), int(q[3])),
(int(q[4]), int(q[5])), (int(q[6]), int(q[7]))]
is_new = False
if q[11] == 0:
is_new = True
if cd is None:
det_xywh2[code][cls] = [[cls, box, score, label_array, color, is_new]]
else:
det_xywh2[code][cls].append([cls, box, score, label_array, color, is_new])
if len(det_xywh2) > 0:
put_queue(image_queue, (1, [det_xywh2, frame, frame_index_list[i], all_frames, draw_config["font_config"]]))
push_p = push_stream_result.result(timeout=60) push_p = push_stream_result.result(timeout=60)
ai_video_file = write_ai_video_result.result(timeout=60) ai_video_file = write_ai_video_result.result(timeout=60)
# 接收停止指令 # 接收停止指令

+ 2
- 2
enums/ModelTypeEnum.py View File

'dmprimg_size': 640, 'dmprimg_size': 640,
'mixFunction': { 'mixFunction': {
'function': dmpr_yolo, 'function': dmpr_yolo,
'pars': {'carCls': 0, 'illCls': 3}
'pars': {'carCls': 0, 'illCls': 3, 'scaleRatio': 0.5}
} }
}, },
'postFile': { 'postFile': {
"name": "post_process", "name": "post_process",
"conf_thres": 0.25,
"conf_thres": 0.8,
"iou_thres": 0.45, "iou_thres": 0.45,
"classes": 5, "classes": 5,
"rainbows": COLOR "rainbows": COLOR

+ 2
- 2
enums/ModelTypeEnum2.py View File

'dmprimg_size': 640, 'dmprimg_size': 640,
'mixFunction': { 'mixFunction': {
'function': dmpr_yolo, 'function': dmpr_yolo,
'pars': {'carCls': 0, 'illCls': 3}
'pars': {'carCls': 0, 'illCls': 3, 'scaleRatio': 0.5}
} }
}, },
'Segweights': '../AIlib2/weights/cityMangement2/dmpr_%s.engine' % gpuName, 'Segweights': '../AIlib2/weights/cityMangement2/dmpr_%s.engine' % gpuName,
'postFile': { 'postFile': {
"name": "post_process", "name": "post_process",
"conf_thres": 0.25,
"conf_thres": 0.8,
"iou_thres": 0.45, "iou_thres": 0.45,
"classes": 5, "classes": 5,
"rainbows": COLOR "rainbows": COLOR

+ 5
- 2
util/PlotsUtils.py View File

return np.asarray(param[0][0:4], np.int32), float(param[1]), int(param[2]) return np.asarray(param[0][0:4], np.int32), float(param[1]), int(param[2])




def draw_painting_joint(box, img, label_array, score=0.5, color=None, config=None):
def draw_painting_joint(box, img, label_array, score=0.5, color=None, config=None, isNew=False):
# 识别问题描述图片的高、宽 # 识别问题描述图片的高、宽
lh, lw = label_array.shape[0:2] lh, lw = label_array.shape[0:2]
# 图片的长度和宽度 # 图片的长度和宽度
8. lineType:线条的类型,可以是cv2.LINE_AA表示抗锯齿线条,或cv2.LINE_4表示4连通线条,或cv2.LINE_8表示8连通线条。默认值为cv2.LINE_8。 8. lineType:线条的类型,可以是cv2.LINE_AA表示抗锯齿线条,或cv2.LINE_4表示4连通线条,或cv2.LINE_8表示8连通线条。默认值为cv2.LINE_8。
9. bottomLeftOrigin:文本起始位置是否为左下角。如果为True,则文本起始位置为左下角,否则为左上角。默认值为False。 9. bottomLeftOrigin:文本起始位置是否为左下角。如果为True,则文本起始位置为左下角,否则为左上角。默认值为False。
''' '''
cv2.putText(img, label, p3, 0, config[3], [225, 255, 255], thickness=config[4], lineType=cv2.LINE_AA)
if isNew:
cv2.putText(img, label, p3, 0, config[3], [0, 0, 0], thickness=config[4], lineType=cv2.LINE_AA)
else:
cv2.putText(img, label, p3, 0, config[3], [225, 255, 255], thickness=config[4], lineType=cv2.LINE_AA)
return img, box return img, box


def filterBox(det0, det1, pix_dis): def filterBox(det0, det1, pix_dis):

Loading…
Cancel
Save