zoukankan      html  css  js  c++  java
  • 使用face_recognition批量识别图片中的人数

    #使用face_recognition实现从图片中选中人数并分别输出txt




    import
    face_recognition import cv2 import os fin = 'D:\Users\a\Pictures\test_pho' # 读取图片并识别人脸 for file in os.listdir(fin): file_fullname = fin + '/' + file img = face_recognition.load_image_file(file_fullname) face_locations = face_recognition.face_locations(img) print(face_locations) faceNum = len(face_locations) print(faceNum) num = str(faceNum) file_object = open(file_fullname+'.txt', 'w') file_object.write(num+ '个人') file_object.close() # 调用opencv函数显示图片 # img = cv2.imread("D:\Users\a\Pictures\test_pho\3.jpg") # cv2.namedWindow("pre_pho") # cv2.imshow("pre_pho", img) #遍历每个人脸,并标注 # faceNum = len(face_locations) # print(faceNum) for i in range(0, faceNum): top = face_locations[i][0] right = face_locations[i][1] bottom = face_locations[i][2] left = face_locations[i][3] start = (left, top) end = (right, bottom) color = (55, 255, 155) thickness = 3 cv2.rectangle(img, start, end, color, thickness) # 显示识别结果 # cv2.namedWindow("rec_pho") # cv2.imshow("rec_pho", img) cv2.waitKey(0) cv2.destroyAllWindows()

  • 相关阅读:
    ec20 queclocator V1. 0 test
    javascript JSON.parse and JSON.stringify
    linux command pushd popd
    learning gcc #pragma once
    learning gcc __BEGIN_DECLS and __END_DECLS
    aarch-linux-gnu-g++ install
    启用”开始“菜单中的“运行”功能
    获取本机安装的软件清单
    固定任务栏
    优化菜单显示速度
  • 原文地址:https://www.cnblogs.com/ansang/p/7895059.html
Copyright © 2011-2022 走看看