|
|
@@ -37,7 +37,7 @@ def get_postProcess_para(parfile): |
|
|
|
|
|
|
|
return parPost["conf_thres"],parPost["iou_thres"],parPost["classes"],parPost["rainbows"]
|
|
|
|
def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'half':True,'device':'cuda:0' ,'conf_thres':0.25,'iou_thres':0.45,'allowedList':[0,1,2,3],'slopeIndex':[5,6,7],'segRegionCnt':1, 'trtFlag_det':False,'trtFlag_seg':False }, font={ 'line_thickness':None, 'fontSize':None,'boxLine_thickness':None,'waterLineColor':(0,255,255),'waterLineWidth':3} ,segPar={'modelSize':(640,360),'mean':(0.485, 0.456, 0.406),'std' :(0.229, 0.224, 0.225),'numpy':False, 'RGB_convert_first':True},mode='others',postPar=None):
|
|
|
|
|
|
|
|
print('########line40:',mode )
|
|
|
|
#输入参数
|
|
|
|
# im0s---原始图像列表
|
|
|
|
# model---检测模型,segmodel---分割模型(如若没有用到,则为None)
|
|
|
@@ -100,21 +100,27 @@ def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'h |
|
|
|
imH,imW = im0s[0].shape[0:2]
|
|
|
|
mmH,mmW = seg_pred.shape[0:2]
|
|
|
|
fx=mmW/imW;fy=mmH/imH
|
|
|
|
|
|
|
|
det_coords=[]
|
|
|
|
|
|
|
|
det_coords_original=[]
|
|
|
|
for box in p_result[2]:
|
|
|
|
if int(box[0]) != 1: continue
|
|
|
|
b_0 = box[1:5]
|
|
|
|
b_0.insert(0,box[0]);b_0.append(box[5] )
|
|
|
|
det_coords_original.append( b_0 )
|
|
|
|
if int(box[0]) != 1: continue
|
|
|
|
b=box[1:5]
|
|
|
|
b[0],b[2] = b[0]*fx,b[2]*fx
|
|
|
|
b[1],b[3] = b[1]*fy,b[3]*fy
|
|
|
|
b=[int(x) for x in b]
|
|
|
|
det_coords.append( (b[0],b[1])); det_coords.append( (b[2],b[3]) )
|
|
|
|
|
|
|
|
postPar['ZoomFactor']={'x':mmW/imW ,'y':mmH/imH}
|
|
|
|
postPar['mask']=seg_pred;postPar['det']=deepcopy(det_coords_original)
|
|
|
|
postPar['label_info']=label_info
|
|
|
|
tlist = list(postPar.keys()); tlist.sort()
|
|
|
|
|
|
|
|
list8, image,time_infos_p = trafficPostProcessingV2(postPar)
|
|
|
|
|
|
|
|
list8, image,time_infos = trafficPostProcessingV2(postPar)
|
|
|
|
|
|
|
|
|
|
|
|
Accident_results = np.array(list8,dtype=object)
|
|
|
|
acc_det=[]
|
|
|
@@ -126,11 +132,13 @@ def AI_process(im0s,model,segmodel,names,label_arraylist,rainbows,objectPar={ 'h |
|
|
|
acc_det.append(box_acc)
|
|
|
|
p_result[1] = draw_painting_joint(xyxy,p_result[1],label_arraylist[int(cls)],score=conf,color=rainbows[int(cls)%20],font=font,socre_location="leftBottom")
|
|
|
|
|
|
|
|
p_result[2].extend( acc_det )
|
|
|
|
else:
|
|
|
|
time_infos_p=''
|
|
|
|
time_info = 'letterbox:%.1f, seg:%.1f , infer:%.1f,%s, seginfo:%s, postjudge:%s '%( (time01-time0)*1000, (time1-time01)*1000 ,(time2-time1)*1000,timeOut , segstr.strip(),time_infos_p.strip() )
|
|
|
|
p_result.append(seg_pred_mulcls)
|
|
|
|
det_coords_original.extend(acc_det)
|
|
|
|
p_result[2]= deepcopy(det_coords_original)
|
|
|
|
|
|
|
|
#print( ' time:',time_infos,' results.shape:',Accident_results.shape, p_result[2])
|
|
|
|
time_info = 'letterbox:%.1f, seg:%.1f , infer:%.1f,%s, seginfo:%s'%( (time01-time0)*1000, (time1-time01)*1000 ,(time2-time1)*1000,timeOut , segstr )
|
|
|
|
if mode=='highWay3.0':
|
|
|
|
p_result.append(seg_pred_mulcls)
|
|
|
|
|
|
|
|
return p_result,time_info
|
|
|
|
|