资源简介
使用多层CNN卷积神经网络构建模型,分析人脸的轮廓,将人脸照片数据放入data中进行训练,并且能够对人脸的表情进行分析(高兴、愤怒、难过、一般)

代码片段和文件信息
# /usr/bin/python3
import cv2
import numpy as np
import sys
import tensorflow as tf
from model import predict image_to_tensor deepnn
CASC_PATH = ‘./data/haarcascade_files/haarcascade_frontalface_default.xml‘
cascade_classifier = cv2.CascadeClassifier(CASC_PATH)
EMOTIONS = [‘angry‘ ‘disgusted‘ ‘fearful‘ ‘happy‘ ‘sad‘ ‘surprised‘ ‘neutral‘]
def format_image(image):
if len(image.shape) > 2 and image.shape[2] == 3:
image = cv2.cvtColor(image cv2.COLOR_BGR2GRAY)
faces = cascade_classifier.detectMultiScale(
image
scaleFactor = 1.3
minNeighbors = 5
)
# None is no face found in image
if not len(faces) > 0:
return None None
max_are_face = faces[0]
for face in faces:
if face[2] * face[3] > max_are_face[2] * max_are_face[3]:
max_are_face = face
# face to image
face_coor = max_are_face
image = image[face_coor[1]:(face_coor[1] + face_coor[2]) face_coor[0]:(face_coor[0] + face_coor[3])]
# Resize image to network size
try:
image = cv2.resize(image (48 48) interpolation=cv2.INTER_CUBIC)
except Exception:
print(“[+} Problem during resize“)
return None None
return image face_coor
def face_dect(image):
“““
Detecting faces in image
:param image:
:return: the coordinate of max face
“““
if len(image.shape) > 2 and image.shape[2] == 3:
image = cv2.cvtColor(image cv2.COLOR_BGR2GRAY)
faces = cascade_classifier.detectMultiScale(
image
scaleFactor = 1.3
minNeighbors = 5
)
if not len(faces) > 0:
return None
max_face = faces[0]
for face in faces:
if face[2] * face[3] > max_face[2] * max_face[3]:
max_face = face
face_image = image[max_face[1]:(max_face[1] + max_face[2]) max_face[0]:(max_face[0] + max_face[3])]
try:
image = cv2.resize(face_image (48 48) interpolation=cv2.INTER_CUBIC) / 255.
except Exception:
print(“[+} Problem during resize“)
return None
return face_image
def resize_image(image size):
try:
image = cv2.resize(image size interpolation=cv2.INTER_CUBIC) / 255.
except Exception:
print(“+} Problem during resize“)
return None
return image
def draw_emotion():
pass
def demo(modelPath showBox=False):
x = tf.placeholder(tf.float32 [None 2304])
y_conv = deepnn(x)
probs = tf.nn.softmax(y_conv)
saver = tf.train.Saver()
ckpt = tf.train.get_checkpoint_state(modelPath)
sess = tf.Session()
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess ckpt.model_checkpoint_path)
print(‘Restore model sucsses!!‘)
feelings_faces = []
for index emotion in enumerate(EMOTIONS):
feelings_faces.append(cv2.imread(‘./data/emojis/‘ + emotion + ‘.png‘ -1))
video_captor = cv2.VideoCapture(0)
emoji_face = []
result = None
while True:
ret frame = video_captor.read()
detected_face face_coor = format_image(frame)
if showBox:
if face_coor is not None:
[xywh] = face_coor
cv2.rectangle(frame (xy) (x+wy+h) (25500
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-11 10:45 Facial-ex
文件 35140 2018-01-11 10:45 Facial-ex
文件 1438 2018-01-11 10:45 Facial-ex
文件 629880 2018-01-11 10:45 Facial-ex
目录 0 2018-01-11 10:45 Facial-ex
目录 0 2018-01-11 10:45 Facial-ex
文件 14628 2018-01-11 10:45 Facial-ex
文件 16186 2018-01-11 10:45 Facial-ex
文件 16175 2018-01-11 10:45 Facial-ex
文件 16613 2018-01-11 10:45 Facial-ex
文件 12094 2018-01-11 10:45 Facial-ex
文件 16397 2018-01-11 10:45 Facial-ex
文件 14663 2018-01-11 10:45 Facial-ex
目录 0 2018-01-11 10:45 Facial-ex
文件 341406 2018-01-11 10:45 Facial-ex
文件 930126 2018-01-11 10:45 Facial-ex
文件 3961 2018-01-11 10:45 Facial-ex
文件 1052 2018-01-11 10:45 Facial-ex
文件 4815 2018-01-11 10:45 Facial-ex
文件 4227 2018-01-11 10:45 Facial-ex
- 上一篇:编译原理 算符优先分析程序
- 下一篇:labview小游戏之登陆月球
相关资源
- 一个人脸识别程序源码
- LDA 人脸识别
- halcon简单实现人脸识别.hdev
- 人脸识别开源SDK源码
- 百度人脸识别Demo
- delphi百度人脸识别离线SDK demo
- 讯飞人脸识别eclipse版
- Delphi7调用虹软人脸识别的测试
- [b115]FPGA上运行人脸识别源代码.zip
- shape_predictor_68_face_landmarks.dat.bz2 68个标
- labview人脸识别283682
- 一种基于LBP和CNN的人脸识别算法
- 基于CAFFE的人脸识别系统
- LabVIEW的人脸识别代码
- 基于深度学习实现人脸识别包含模型
- 人脸识别必备的FERET人脸数据库
- 经典的人脸识别论文,包含中、英文
- H5人脸识别+活体检测眨眼摇头
- 人脸识别图像预处理技术
- iOS平台下人脸识别系统实现研究
- 人脸识别数据集说明及其
- 卷积神经网络的人脸识别样本采集+
- STM32人脸识别代码
- 科大讯飞 语音听写 人脸识别 sdk
- 基于PCA的人脸识别技术的研究
- 基于LBP算法的人脸识别研究
- 人脸识别SDK免费,可商用,有演示、
- 人脸识别三套源码含小程序源码亲测
- 基于神经网络的人脸识别(附代码)
- 基于多任务卷积网络(MTCNN)和Cente
评论
共有 条评论