zoukankan      html  css  js  c++  java
  • 基于人脸识别技术的人证比对访客系统

    最近有个小区用到了虹软的人脸识别,效果还不错。又有一个项目要用人证访客对比,分享一下项目,希望可以帮到有需要的。
    码字前先上项目地址:https://gitee.com/panmingzhi/IdCardFaceIdentifier
    首先是读证的问题,我们使用的是华视CVR100U,公司已经用这个型号6年了,以前一卡通的资料都用它录,除了不好看,质量杠杠的。大部人的身份证都是很多年前办理的,所有比对的相似度不要太高。
    视频采集还是使用的Aforge,使用 NewFrame 一方面要显示到实时画面,另一方面要异步的与当前读到的证件进行比对。这里请不尝试在NewFrame回调事件中直接显示到pictureBox,请使用如下方式,百试不爽:

            private void VideoCaptureDevice_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
            {
                Bitmap newFrame = (Bitmap)eventArgs.Frame.Clone();
                //如果使用视频文件请注释下面的这行代码,表示不对图像进行水平翻转
                newFrame.RotateFlip(RotateFlipType.Rotate180FlipY);
                lock (sync)
                {
                    if (currentFrame != null)
                    {
                        currentFrame.Dispose();
                        currentFrame = null;
                    }
                    currentFrame = newFrame;
                    skinPictureBox2.Invalidate();
                }
            }
            /**
             * 绘制当前帧到控制,必须与获取当前帧互斥
             */
            private void skinPictureBox2_Paint(object sender, PaintEventArgs e)
            {
                lock (synCurrentMat)
                {
                    Bitmap bitmap = GetCurrentFrame();
                    if (bitmap != null)
                    {
                        e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, skinPictureBox2.Width, skinPictureBox2.Height), new Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel);
                    }
                }
            }
    //异步的人证对比时,使用此方法再获取实时截图
            public Bitmap GetCurrentFrame()
            {
                if (captureToken.Token.IsCancellationRequested) return null;
                lock (sync)
                {
                    return (currentFrame == null || currentFrame.Width == 0 || currentFrame.Height == 0) ? null : AForge.Imaging.Image.Clone(currentFrame);
                }
            }

    二代证身份证的读取频率是每1秒读一次,读到证件后,10秒内为人证比对时间,这10秒将不再读证。10秒内比对成功,显示成功提示2-3秒后,重新再开始读证。
    在读证时,如果证件被正确读取到后,要重新拿开再放置证件,这个在华视的产品说明书与SDK都有说明,其它厂家如鼎识也是一样的。
    华视阅读器读到的身份证图片与证件信息默认保存在SDK目录下的wz.txt与wz.bmp,使用wz.bmp做比对时,经常报内存出错,后面我将bmp先转成jpg保存一次后再做人证比对,似乎就没问题。
    证件比对时还是延续了之前方式,先将证件图片解析成FaceModel,然后将当前视频截图连续与些FaceModel比对,每次读到证件时都更新一次FaceModel。

            /**
             * 绘制当前帧到控制,必须与获取当前帧互斥
             */
            private void skinPictureBox2_Paint(object sender, PaintEventArgs e)
            {
                lock (synCurrentMat)
                {
                    Bitmap bitmap = GetCurrentFrame();
                    if (bitmap != null)
                    {
                        e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, skinPictureBox2.Width, skinPictureBox2.Height), new Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel);
                    }
                }
            }
    //异步的人证对比时,使用此方法再获取实时截图
            public Bitmap GetCurrentFrame()
            {
                if (captureToken.Token.IsCancellationRequested) return null;
                lock (sync)
                {
                    return (currentFrame == null || currentFrame.Width == 0 || currentFrame.Height == 0) ? null : AForge.Imaging.Image.Clone(currentFrame);
                }
            }

    这是截图:(本人不上像,鬼画桃胡将就一下)

    1、提示放证

    2、读到证件后立即比对

    3、比对显示结果后将重新回到第一步

    如果有问题的话欢迎多多交流
    原帖地址
    实战开发分享,关于人证比对访客系统的问题都可以问

  • 相关阅读:
    MyBatis-XML和注解
    spring-Servlet/Tomcat/Spring
    spring-过滤器与拦截器
    spring-spring task原理及使用
    spring-事务源码解析-todo
    架构设计-SOA架构和微服务架构的区别
    架构设计-微服务架构初步学习
    Python 中 OS 模块获取文件/目录路径方法
    python 中 pymysql 模块链接 MySQL 数据库,进行数据验证及封装
    Python 接口测试的步骤、特点、关注点、get和post 区别
  • 原文地址:https://www.cnblogs.com/KEAIILINN/p/10619739.html
Copyright © 2011-2022 走看看