【问题标题】:Face verification of given bounding box给定边界框的人脸验证
【发布时间】:2021-03-22 17:31:27
【问题描述】:

我正在使用face_recognition的python库进行人脸识别演示。

 # Grab a single frame of video
    ret, frame = video_capture.read()

    # Resize frame of video to 1/4 size for faster face recognition processing
    small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)

    # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
    rgb_small_frame = small_frame[:, :, ::-1]

    # Only process every other frame of video to save time
    # Find all the faces and face encodings in the current frame of video
    face_locations = face_recognition.face_locations(rgb_small_frame) 

上面的代码,据我所知,检测给定框架中不同大小的人脸。如果我想绘制一个边界框,并且如果该边界框上有一个人脸,那么只有那个人脸应该用于进一步处理。我的 CPU 不会检测整个帧中不同大小的人脸,而只能从具有固定大小的感兴趣区域检测人脸。

【问题讨论】:

    标签: python face-detection face-recognition


    【解决方案1】:

    复制图像,将其裁剪为仅边界框,然后对新裁剪的图像运行人脸识别。

    # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
    rgb_small_frame = small_frame[:, :, ::-1]
    #crop image based on some bounding box
    rgb_cropped = rgb_small_frame[boundy1:boundy2,boundx1,boundx2]
    
    # Only process every other frame of video to save time
    # Find all the faces and face encodings in the current frame of video
    face_locations = face_recognition.face_locations(rgb_cropped) 
    

    【讨论】:

    • 谢谢杰夫,但它仍然会在该裁剪图像上滑动不同大小的边界框。我只想限制特定大小的脸。
    • 该模块将找到图像中的所有面孔,我认为您必须实施一些后处理以根据尺寸消除不需要的特征
    【解决方案2】:

    你为什么不试试 deepface?只需一行代码即可实时应用人脸识别。

    #!pip install deepface
    from deepface import DeepFace
    DeepFace.stream(db_path = "C:/my_db")
    

    这里,您应该将面部图像数据库存储在 C:/my_db 文件夹中。

    【讨论】:

      猜你喜欢
      • 2011-06-25
      • 1970-01-01
      • 2016-02-25
      • 2019-06-18
      • 2020-01-22
      • 2012-04-17
      • 1970-01-01
      • 2020-12-26
      • 2020-12-31
      相关资源
      最近更新 更多