在官方github文件内自带这个功能
链接:nvdia-deepstream-py
使用了opencv
实现功能函数如下:
下面展示一些 内联代码片
。
def draw_bounding_boxes(image,obj_meta,confidence):
confidence='{0:.2f}'.format(confidence)
rect_params=obj_meta.rect_params
top=int(rect_params.top)
left=int(rect_params.left)
width=int(rect_params.width)
height=int(rect_params.height)
obj_name=pgie_classes_str[obj_meta.class_id]
image=cv2.rectangle(image,(left,top),(left+width,top+height),(0,0,255,0),2)
# Note that on some systems cv2.putText erroneously draws horizontal lines across the image
image=cv2.putText(image,obj_name+',C='+str(confidence),(left-10,top-10),cv2.FONT_HERSHEY_SIMPLEX,0.5,(0,0,255,0),2)
return image