最近看机器学习,神经网络,图像识别是这个领域很常见的一种应用。使用著名的dlib库和微软RENET 68点模型做人脸识别,准确率高。
这程序演示了基本功能。
运行需要 shape_predictor_68_face_landmarks.dat, dlib_face_recognition_resnet_model_v1.dat,这两个数据文件,可在网上下载,
把需要识别的人脸照片 放在一个目录就可以了。
代码如下,转载请注明原文链接
# -*- coding: UTF-8 -*-
# weixin: yyckwen
# 2017/08/31 import sys,os,dlib,glob,numpy from skimage import io import pickle import time import cv2 import win32com.client import threading import queue import random from queue import Queue class langduface(threading.Thread): def __init__(self,f_name,speaker,pool): threading.Thread.__init__(self,name=f_name) self.data = pool self.speaker = speaker def run(self): yy = 1 while 1: try: n = self.data.get(1,10) print('pool:',self.data.qsize(),yy) if yy%10 == 1: self.speaker.Speak("欢迎, " + n) yy = yy + 1 except