Advertisement

Python OpenCV 2绘制行人检测框常用代码

阅读量:
复制代码
    import cv2
    import numpy as np
    
    def cv_imread(filePath):
    cv_img = cv2.imdecode(np.fromfile(filePath,dtype=np.uint8), -1)
    return cv_img
    
    # 需要可视化的图片地址
    img_path = ‘’
    # 对应图片的检测结果
    detection_result = []
    
    # 如果路径中包含中文,则需要用函数cv_imread的方式来读取,否则会报错
    img = cv_imread(img_path)
     # 可视化
    for bb in detection_result:
    # bb的格式为:[xmin, ymin, xmax, ymax]
    cv2.rectangle(img, (int(bb[0]), int(bb[1])),
                        (int(bb[2]), int(bb[3])),
                         (255, 0, 0), 2)
    
    cv2.imshow('1', img)
    cv2.waitKey(0)
    

全部评论 (0)

还没有任何评论哟~