• 使用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()

  • 相关阅读:
    eclipse中的TODO和FIXME
    使用mui框架后a标签无法跳转
    java.lang.OutOfMemoryError: Java heap space异常
    mysql中表触发器的简单使用
    编写第一个 Java 程序
    QDialog类exec()与show()的区别
    Qt中信号槽connect的多种类型
    2.3 UML活动图
    2.2 UML用例模型
    2.1 uml序言
  • 原文地址:https://www.cnblogs.com/ansang/p/7895059.html
Copyright © 2020-2023  润新知