(资料图片)
defwrap_detection(self,input_image,out_data):confidences=[]boxes=[]kypts=[]rows=out_data.shape[0]image_width,image_height,_=input_image.shapex_factor=image_width/640.0y_factor=image_height/640.0sd=np.zeros((5,2),dtype=np.float32)sd[0:5]=(x_factor,y_factor)sd=np.squeeze(sd.reshape((-1,1)),1)#xyxy,lmdks,conf,cls,forrinrange(rows):row=out_data[r]conf=row[14]cls=row[15]if(conf>0.25andcls>0.25):confidences.append(conf)x,y,w,h=row[0].item(),row[1].item(),row[2].item(),row[3].item()left=int((x-0.5*w)*x_factor)top=int((y-0.5*h)*y_factor)width=int(w*x_factor)height=int(h*y_factor)box=np.array([left,top,width,height])boxes.append(box)kypts.append(np.multiply(row[4:14],sd))indexes=cv.dnn.NMSBoxes(boxes,confidences,0.25,0.25)result_confidences=[]result_boxes=[]result_kypts=[]foriinindexes:result_confidences.append(confidences[i])result_boxes.append(boxes[i])result_kypts.append(kypts[i])returnresult_kypts,result_confidences,result_boxes
扫码查看OpenCV+OpenVIO+Pytorch系统化学习路线图
标签:
相关新闻
保险时讯
01-18
09-15
10-21
10-21
10-21
10-21
10-21
10-21
10-21
10-21
聚焦百姓
更多>