# image_face_npy(demo) **Repository Path**: Kozakemi/image_face_npy ## Basic Information - **Project Name**: image_face_npy(demo) - **Description**: 读取目录图片,识别并保存人脸信息 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-01-13 - **Last Updated**: 2023-08-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python, MySQL ## README # image_face_npy(demo) #### 介绍 读取目录图片,识别并保存人脸信息,而不是保存图片,便于保护人员隐私,减少服务器数据被窃取的情况下带来额外损失,且人脸模板预先生成,减少比对时一半运算量(相对于两个图片直接比对) 此代码适合用于人脸认证场合,如门禁等 #### 流程 解析人员信息 写入数据库信息 图片灰度处理,减少干扰 写入人脸模板信息 移除操作成功图片 #### 安装教程 只叙述Ubuntu 20.04 on arm 且拥有 mariadb数据库(10.3.34-MariaDB-0ubuntu0.20.04.1),mysql未测试, 其他运行环境自行研究 ``` shell sudo apt install curl git python3-pip apt install python3-mysqldb pip install cmake pip install boost pip install dlib pip install face_recognition pip install face_recognition pip install opencv-python ``` #### 使用说明 1、安装依赖 2、放入图片 3、运行`main.py` 4、没了,得到了.npy 文件,尝试运用到你自己的项目中吧 #### 使用例 在自己的项目中使用.npy 文件,请自己修改目录等,以配合您的项目 ``` python def facedata_pngComparison(sno): start = time.perf_counter() #计时开始 try: png_path="./human_face/%s/1.jpg"%sno#待检测人脸 np_path="./human_face/%s/2.npy"%sno#模板文件 my_face_encoding = np.load(np_path) #加载 except: print("无npy模板文件",sno) try: unknown_picture = face_recognition.load_image_file(png_path) #待检测人脸 unknown_face_encoding = face_recognition.face_encodings(unknown_picture)[0] results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding,tolerance=0.38)#tolerance越小越严格 # print("已检测到人脸") except: print('待检测人脸特征生成失败') end = time.perf_counter() #计时结束 print("识别耗时:",end - start) try: if results[0]: # "比对成功" return 0 else: 比对失败" return -1 except: return -1 ``` #### 参与贡献 1. Fork 本仓库 kozakemi 2. 新建 Feat_xxx 分支 kozakemi 3. 提交代码 kozakemi 4. 新建 Pull Request kozakemi #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)