人脸识别部分算法

10种轻量级人脸检测算法的比拼

这里的算法复现思路
代码下载地址

v5的视频demo和v3的关键点检测

这里都是基本的读取代码

if __name__ == "__main__" :
    import time
    device = 'cuda' if torch.cuda.is_available() else 'cpu'
    DBface_Detect = dbface_detect(device=device, align=True)

    start_time=time.time()
    cap = cv2.VideoCapture('2560×1440.mp4')

    fourcc = cv2.VideoWriter_fourcc(*'MJPG')
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))//3
    height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))//3
    # print("width:",width, "height:", height)
    video_fps = cap.get(cv2.CAP_PROP_FPS)

    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    out = cv2.VideoWriter('downsample3.mp4', fourcc, video_fps, (width, height))  # 现实的格式尺寸

    # yolonet = yolov5(confThreshold=args.confThreshold, nmsThreshold=args.nmsThreshold,
    #                  objThreshold=args.objThreshold)

    # srcimg = cv2.imread(args.imgpath)
    i=0
    ret, srcimg = cap.read()
    while(ret):
        time_flag1 = time.time()
        srcimg=cv2.resize(srcimg, (width, height))
        # dets = yolonet.detect(srcimg)
        # srcimg = yolonet.postprocess(srcimg, dets)
        # drawimg, face_rois = yoloface_detect.detect(srcimg)
        # drawimg, face_rois = facebox_detect.detect(srcimg)
        drawimg, face_rois = DBface_Detect.detect(srcimg)
        # print("face",face_rois)
        winName = 'Deep learning object detection in OpenCV'

        cv2.namedWindow(winName, 0)
        cv2.imshow(winName, drawimg)
        cv2.waitKey(2)

        i+=1
        time_flag2 = time.time()
        print(f"cost: {time_flag2 - time_flag1}")
        out.write(drawimg)
        ret, srcimg = cap.read()

    end_time = time.time()
    print(f'Done. Total cost: {end_time - start_time}')
    print(f'each image cost: {(end_time - start_time)/i}')
    cap.release()
    out.release()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值