demo_sequence.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:lsi-faster-rcnn 作者: cguindel 项目源码 文件源码
def vis_detections(im, class_name, dets, thresh=0.5):

    global video_writer

    """Draw detected bounding boxes."""
    inds = np.where(dets[:, -1] >= thresh)[0]
    if len(inds) == 0:
        return

    show_im = im.copy()

    for i in inds:
        bbox = dets[i, :4]
        score = dets[i, -1]

        # Rectangle color is brighter if its probability is higher
        if score>0.2:
            cv2.rectangle(show_im,(int(bbox[0]), int(bbox[1])),
                (int(bbox[2]), int(bbox[3])), (0,0,255*score), 3)

        # Draw classic certainty percentage
        # cv2.putText(show_im, '{:.0f}%'.format(score*100),
        #     (int(bbox[0]), int(bbox[1])-10), cv2.FONT_HERSHEY_DUPLEX,
        #     0.6, (0,0,255))

    cv2.imshow("result", show_im)
    key = cv2.waitKey(3)
    if args.record>0:
        if video_writer is None:
            video_writer = cv2.VideoWriter("output.avi", fourcc, 30, (im.shape[1], im.shape[0]))
            print 'VideoWriter is ready'
        video_writer.write(show_im)

    if key==27:    # Esc key to stop
        sys.exit(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号