资源简介
opencv3+python人脸检测和识别 完整项目 识别视频《欢乐颂》中人物

代码片段和文件信息
import os
import sys
import cv2
import numpy as np
def normalize(X low high dtype=None):
“““Normalizes a given array in X to a value between low and high.“““
X = np.asarray(X)
minX maxX = np.min(X) np.max(X)
# normalize to [0...1].
X = X - float(minX)
X = X / float((maxX - minX))
# scale to [low...high].
X = X * (high-low)
X = X + low
if dtype is None:
return np.asarray(X)
return np.asarray(X dtype=dtype)
def read_images(path sz=None):
“““Reads the images in a given folder resizes images on the fly if size is given.
Args:
path: Path to a folder with subfolders representing the subjects (persons).
sz: A tuple with the size Resizes
Returns:
A list [Xy]
X: The images which is a Python list of numpy arrays.
y: The corresponding labels (the unique number of the subject person) in a Python list.
“““
c = 0
Xy = [] []
for dirname dirnames filenames in os.walk(path):
for subdirname in dirnames:
subject_path = os.path.join(dirname subdirname)
for filename in os.listdir(subject_path):
try:
if (filename == “.directory“):
continue
filepath = os.path.join(subject_path filename)
im = cv2.imread(os.path.join(subject_path filename) cv2.IMREAD_GRAYSCALE)
if (im is None):
print (“image “ + filepath + “ is none“)
else:
print (filepath)
# resize to given size (if given)
if (sz is not None):
im = cv2.resize(im (200 200))
X.append(np.asarray(im dtype=np.uint8))
y.append(c)
# except IOError (errno strerror):
# print (“I/O error({0}): {1}“.format(errno strerror))
except:
print (“Unexpected error:“ sys.exc_info()[0])
raise
print (c)
c = c+1
# print (X) #2017-6-11 add
print (y)
return [Xy]
def face_rec():
names = [‘fanshengmei‘]
if len(sys.argv) < 2:
print (“USAGE: facerec_demo.py []“)
sys.exit()
[Xy] = read_images(sys.argv[1])
y = np.asarray(y dtype=np.int32)
if len(sys.argv) == 3:
out_dir = sys.argv[2]
model = cv2.face.createEigenFaceRecognizer()
model.train(np.asarray(X) np.asarray(y))
camera = cv2.VideoCapture(“2.mp4“)
face_cascade = cv2.CascadeClassifier(‘./cascades/haarcascade_frontalface_alt2.xml‘)
while (True):
read img = camera.read()
# faces = face_cascade.detectMultiScale(img 1.3 5)
faces = face_cascade.detectMultiScale(img 1.4 5)
for (x y w h) in faces:
img = cv2.rectangle(img(xy)(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6959124 2017-06-12 00:32 facefs\2.mp4
文件 341406 2016-11-14 23:49 facefs\cascades\haarcascade_eye.xm
文件 601661 2016-11-14 23:49 facefs\cascades\haarcascade_eye_tree_eyeglasses.xm
文件 676709 2016-11-14 23:49 facefs\cascades\haarcascade_frontalface_alt.xm
文件 540616 2016-11-14 23:49 facefs\cascades\haarcascade_frontalface_alt2.xm
文件 2689040 2016-11-14 23:49 facefs\cascades\haarcascade_frontalface_alt_tree.xm
文件 930127 2016-11-14 23:49 facefs\cascades\haarcascade_frontalface_default.xm
文件 476825 2016-11-14 23:49 facefs\cascades\haarcascade_fullbody.xm
文件 195369 2016-11-14 23:49 facefs\cascades\haarcascade_lefteye_2splits.xm
文件 47775 2016-11-14 23:49 facefs\cascades\haarcascade_licence_plate_rus_16stages.xm
文件 395320 2016-11-14 23:49 facefs\cascades\haarcascade_lowerbody.xm
文件 828514 2016-11-14 23:49 facefs\cascades\haarcascade_profileface.xm
文件 196170 2016-11-14 23:49 facefs\cascades\haarcascade_righteye_2splits.xm
文件 75482 2016-11-14 23:49 facefs\cascades\haarcascade_russian_plate_number.xm
文件 188650 2016-11-14 23:49 facefs\cascades\haarcascade_smile.xm
文件 785817 2016-11-14 23:49 facefs\cascades\haarcascade_upperbody.xm
文件 590 2017-06-11 18:14 facefs\data\at\faceshls.csv
文件 40015 2017-06-11 18:09 facefs\data\at\fs\0.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\1.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\10.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\11.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\12.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\13.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\15.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\16.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\17.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\18.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\19.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\2.pgm
文件 40015 2017-06-11 18:09 facefs\data\at\fs\20.pgm
............此处省略47个文件信息
相关资源
- Python 人脸识别
- python人脸识别(opencv)
- python 照片人脸识别
- 基于K210开发的人脸特征识别2020电赛(
- 人脸检测和识别(opencv3+python)
- python3.5 百度ai人脸识别
- python基于人脸检测和人脸识别
- Python-pytorch实现的人脸检测和人脸识别
- dlib-19.18.0-cp37-cp37m-linux_armv7l.whl
- 人脸识别算法,双2D2DPCALBP余弦相似度
- MATLAB版本的2Dpca和欧式距离算法
- Python-PCA降维人脸识别,已包含yale数据
- 人脸识别算法 python
- dlib18.17 编译好的python-dlib库 不需要
- python人脸识别截取
- 人脸识别图片集(刘德华吴彦祖)
- 利用python和opencv进行人脸识别
- 人脸识别-python-特征脸-PCA
- opencv3+python人脸检测和识别- 完整实战
- 人脸识别python代码187268
- opencv3+python人脸检测和识别- 完整实战
- dlib-19.17.0-py3.7-win-amd64.egg.zip免去复杂
- 西电数据挖掘作业——VSM人脸识别算
- 基于Tensorflow的人脸识别源码
-
树莓派人脸识别python代码及xm
l模型 - python + opencv 人脸识别代码(可以跨平
- python人脸识别
- 人脸识别门禁系统 毕业设计 可移植
- Python人脸识别自动筛选抖音女神小姐
- python调用dlib库实现简单的人脸识别
评论
共有 条评论