欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

基于face_recognition 人脸识别系统安装实现说明书

发布时间:2025/3/18 64 豆豆
生活随笔 收集整理的这篇文章主要介绍了 基于face_recognition 人脸识别系统安装实现说明书 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

为什么80%的码农都做不了架构师?>>>   

 

目  录

第一章 系统说明:. 3

第二章 安装. 4

第三章 API 5

获取人脸图片编码. 5

获取人脸位置. 5

添加人脸数据. 6

两人脸特征码对比. 6

两张照片对比. 7

人脸特征码人脸库匹配. 7

照片人脸库匹配. 8

第四章 系统集成. 9

第五章 人脸系统使用说明. 10

运行. 10

配置. 10

数据库表. 11

 

 

 

 

  • 系统说明:

本系统是基于face_recognition项目来开发的,使用django提供restful API接口。

    环境要求:

ubuntu 16/17、python3、django、PIL、postgresql9.6                                                                                

  • 安装

在ubuntu中安装:

第一步安装python环境:

  • python3 #查看python版本
  • sudo apt-get install python3-pip
  • sudo pip3 install django
  • sudo pip3 install numpy #更新为最新的数学计算库
  • sudo pip3 install psycopg2 #安装数据库包
  • sudo pip3 install psycopg2-binary
  •  

    第二步安装face_recognition:

  • sudo apt-get upgrade #更新库
  • sudo apt-get install build-essential cmake
  • sudo apt-get install libgtk-3-dev
  • sudo apt-get install libboost-all-dev
  • sudo pip3 install dlib
  • sudo pip3 install face_recognition
  • face_recognition #测试是否安装成功 查看命令是否能够正常调用
  • 说明:确保系统中有python3.5+版本。建议升级为3.6最新版本。

    选择安装postgresql:

  • sudo apt-get install postgresql
  • 配置数据库:

  • 数据库账号密码
  • sudo su postgres #切换postgresql 系统用户
  • psql #进入psql命令 注意分号,表示sql 语句完成
  • ALTER USER postgres WITH PASSWORD 'postgres';
  •  

     

  • 数据库IP访问
  • cd /etc/postgresql/9.6/main #进入配置目录
  • sudo vim pg_hba.conf
  • #添加如下 开放外部访问
  • host    all            all          0.0.0.0/0            md5
  • #:wq 保存修改
  • sudo vim posgresql.conf
  • listen_addresses = '0.0.0.0'#修改监听ip
  • #:wq 保存修改
  • #重启postgresql
  • sudo /etc/init.d/postgresql restart
  •  

    • API
      •  

    REQUEST

    URI/face/enCode

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    img

    string

     

    base64图片编码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    string[]

     

    人脸特征码数组

    time

    double

     

    执行时间

      •  

    REQUEST

    URI/face/locations

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    img

    string

     

    base64图片编码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    json[]

     

    位置组,包含截取的img64代码

    time

    double

     

    执行时间

     

      •  

    REQUEST

    URI/face/addFace

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    img

    string

     

    base64图片编码

     

    id

    string

     

    唯一值

    name

    string

     

    姓名

    code

    string

     

    人脸特征码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    msg

    string

     

    消息

    time

    double

     

    执行时间

      •  

    REQUEST

    URI/face/compare2code

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    code1

    string

     

    人脸特征码

     

    code2

    string

     

    人脸特征码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    int

     

    是否匹配,1:匹配,0:不匹配

    time

    double

     

    执行时间

    两张照片对比

    REQUEST

    URI/face/compare2img

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    img1

    string

     

    base64图片编码

    img2

    string

     

    base64图片编码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    int

     

    是否匹配,1:匹配,0:不匹配

    time

    double

     

    执行时间

      •  

    REQUEST

    URI/face/verifyByCode

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    code

    string

     

    人脸特征码

     

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    int

     

    是否匹配,1:匹配,0:不匹配

    time

    double

     

    执行时间

    照片人脸库匹配

    REQUEST

    URI/face/verifyByImg

    method: post

    参数名

    类型

    是否必填

    默认值

    说明

    img

    string

     

    base64图片编码

    RESPONSE

    参数名

    类型

    默认值

    说明

    code

    int

     

    状态码 1:成功,0:失败

    value

    int

     

    是否匹配,1:匹配,0:不匹配

    time

    double

     

    执行时间

     

     

     

     

    • 系统集成

    业务系统根据需求选择第三章中的对应接口来使用本系统。

    调用方式如下时序图:

     

     

    • 人脸系统使用说明
      •  

    执行~/workspace/faceService/run.sh

      •  

    人脸系统配置分为外部数据库配置、django配置、人脸相识值。

    数据库配置:

    文件:/faceService/faceService/settings.py

    # Database

    # https://docs.djangoproject.com/en/1.11/ref/settings/#databases

     

    DATABASES = {

        'default': {

            'ENGINE': 'django.db.backends.postgresql_psycopg2',

            'NAME': 'face',

            'USER':'postgres',

            'PASSWORD':'postgres',

            # 'HOST':'192.168.10.185',

            'HOST':'127.0.0.1',

            'POST':'5432'

        }

    }

    django运行设置:

    文件:/faceService/run.sh

    python3 manage.py runserver 0.0.0.0:8000 #对应ip 和端口

    人脸相识值:

    文件:/faceService/app/FaceApi.py

    # 最大相似度 越小越相似

    max_distance=0.4

      •  

    人脸表:face

       

    字段

    数据类型

    说明

    id

    Character Varying( 50 )

    主键,可以是身份证号,或业务系统数据id

    name

    Character Varying( 50 )

    姓名

    code

    text

    特征码

    img

    text

    base64图片

     

     

    转载于:https://my.oschina.net/loyin/blog/3043044

    与50位技术专家面对面20年技术见证,附赠技术全景图

    总结

    以上是生活随笔为你收集整理的基于face_recognition 人脸识别系统安装实现说明书的全部内容,希望文章能够帮你解决所遇到的问题。

    如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。