记录下关于虹软人脸验证
1先启动摄像头
属性
/// <summary>
/// 视频输入设备信息
/// </summary>
private FilterInfoCollection filterInfoCollection;
/// <summary>
/// RGB摄像头设备
/// </summary>
private VideoCaptureDevice rgbDeviceVideo;
/// <summary>
/// IR摄像头设备
/// </summary>
private VideoCaptureDevice irDeviceVideo;
/// <summary>
/// RGB 摄像头索引
/// </summary>
private int rgbCameraIndex = 0;
/// <summary>
/// IR 摄像头索引
/// </summary>
private int irCameraIndex = 0;
public FaceForm()
{
InitializeComponent();
this.rgbVideoSource.Paint += new System.Windows.Forms.PaintEventHandler(this.videoSource_Paint);
CheckForIllegalCrossThreadCalls = false;
//初始化引擎
//InitEngines();
lblMessage.Text = FaceCompare.InitEngines();
if (lblMessage.Text != "请启动摄像头")
{
//初始化失败
return;
}
//隐藏摄像头图像窗口
rgbVideoSource.Hide();
irVideoSource.Hide();
//从配置文件读取摄像头序号
AppSettingsReader reader = new AppSettingsReader();
rgbCameraIndex = (int)reader.GetValue("RGB_CAMERA_INDEX", typeof(int));
irCameraIndex = (int)reader.GetValue("IR_CAMERA_INDEX", typeof(int));
//注册一张人脸到人脸库,如果要注册多张循环调用就可以了
//先清空控件
imageList.Images.Clear();
var resultsdata = UserBLL.GetUsersList("","");
//员工人脸集合
foreach (var item in resultsdata)
{
Image img1 = Image.FromFile(item.user_photo, true); //创建 Image 对象
FaceCompare.RegisterImage(img1, item.user_number, item.user_name);
imageList.Images.Add(img1);
}
}
/// <summary>
/// RGB摄像头Paint事件,图像显示到窗体上,得到每一帧图像,并进行处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void videoSource_Paint(object sender, PaintEventArgs e)
{
if (rgbVideoSource.IsRunning)
{
//得到当前RGB摄像头下的图片
Bitmap bitmap = rgbVideoSource.GetCurrentVideoFrame();
FaceCompareResult result = FaceCompare.DoRgbCompare(bitmap,e);
if (result.faceIndex >= 0)
{
if (bitmap != null)
{
// imageList
pictureBox1.Image = bitmap;
Image img = bitmap;
lblMessage.Text = "识别成功:\r\n" + result.msg + ";\r\n打卡成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
lblMessage.Text = "识别失败:\r\n" + result.msg + ";\r\n打卡失败:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
else
{
pictureBox1.Image = null;
lblMessage.Text = "识别失败:\r\n" + result.msg + ";\r\n打卡失败:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
// 启动摄像头
private void btnStartVideo_Click(object sender, EventArgs e)
{
//在点击开始的时候再坐下初始化检测,防止程序启动时有摄像头,在点击摄像头按钮之前将摄像头拔掉的情况
InitVideo();
//必须保证有可用摄像头
if (filterInfoCollection.Count == 0)
{
MessageBox.Show("未检测到摄像头,请确保已安装摄像头或驱动!");
return;
}
if (rgbVideoSource.IsRunning || irVideoSource.IsRunning)
{
btnStartVideo.Text = "启用摄像头";
//关闭摄像头
if (irVideoSource.IsRunning)
{
irVideoSource.SignalToStop();
irVideoSource.Hide();
}
if (rgbVideoSource.IsRunning)
{
rgbVideoSource.SignalToStop();
rgbVideoSource.Hide();
}
}
else
{
//“选择识别图”、“开始匹配”按钮禁用,阈值控件可用,显示摄像头控件
rgbVideoSource.Show();
irVideoSource.Show();
btnStartVideo.Text = "关闭摄像头";
//获取filterInfoCollection的总数
int maxCameraCount = filterInfoCollection.Count;
//如果配置了两个不同的摄像头索引
if (rgbCameraIndex != irCameraIndex && maxCameraCount >= 2)
{
//RGB摄像头加载
rgbDeviceVideo = new VideoCaptureDevice(filterInfoCollection[rgbCameraIndex < maxCameraCount ? rgbCameraIndex : 0].MonikerString);
rgbDeviceVideo.VideoResolution = rgbDeviceVideo.VideoCapabilities[0];
rgbVideoSource.VideoSource = rgbDeviceVideo;
rgbVideoSource.Start();
//IR摄像头
irDeviceVideo = new VideoCaptureDevice(filterInfoCollection[irCameraIndex < maxCameraCount ? irCameraIndex : 0].MonikerString);
irDeviceVideo.VideoResolution = irDeviceVideo.VideoCapabilities[0];
irVideoSource.VideoSource = irDeviceVideo;
irVideoSource.Start();
//双摄标志设为true
isDoubleShot = true;
}
else
{
//仅打开RGB摄像头,IR摄像头控件隐藏
rgbDeviceVideo = new VideoCaptureDevice(filterInfoCollection[rgbCameraIndex <= maxCameraCount ? rgbCameraIndex : 0].MonikerString);
rgbDeviceVideo.VideoResolution = rgbDeviceVideo.VideoCapabilities[0];
rgbVideoSource.VideoSource = rgbDeviceVideo;
rgbVideoSource.Start();
irVideoSource.Hide();
}
//按摄像头分辨率设置画面的比例
var videoWidth = rgbDeviceVideo.VideoResolution.FrameSize.Width;
var videoHeight = rgbDeviceVideo.VideoResolution.FrameSize.Height;
rgbVideoSource.Height = int.Parse((videoHeight * rgbVideoSource.Width / videoWidth).ToString());
FaceCompare.VideoSource = rgbVideoSource;
}
}
/// <summary>
/// 摄像头初始化
/// </summary>
private void InitVideo()
{
filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
//如果没有可用摄像头,“启用摄像头”按钮禁用,否则使可用
if (filterInfoCollection.Count == 0)
{
lblMsg.Text = "没有摄像头";
// btnStartVideo.Enabled = false;
}
else
{
lblMsg.Text = "已初始化摄像头";
// btnStartVideo.Enabled = true;
}
}
/// <summary>
/// 窗体关闭事件
/// </summary>
private void FaceForm2_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
if (rgbVideoSource.IsRunning)
{
btnStartVideo_Click(sender, e); //关闭摄像头
}
FaceCompare.UninitEngine();
}
catch (Exception ex)
{
Console.WriteLine("UninitEngine pImageEngine Error:" + ex.Message);
}
}
记录下关于虹软人脸验证相关推荐
- pb 调用虹软_记C# 调用虹软人脸识别 那些坑
上一个东家是从事安防行业的,致力于人工智能领域,有自主人脸识别.步态识别的算法.C++同事比较称职有什么问题都可以第一时间反馈,并得到合理的处理,封装的DLL 是基于更高性能的GPU算法,可支持更多线 ...
- 人脸验证(三)--FaceNet
转自:blog.csdn.net/stdcoutzyx/article/details/46687471 引入 随着深度学习的出现,CV领域突破很多,甚至掀起了一股CV界的创业浪潮,当次风口浪尖之时, ...
- 基于RTSP视频流的Java后台服务端虹软人脸识别
1 概述 人脸识别技术是随着技术发展而产生的生物识别技术,目前已广泛应用于安防领域,主要用于身份验证和身份识别.视频监控是安防系统常见的一种表现形式,需要部署各种摄像头,包括网络摄像头IP ...
- 深度学习(十八):人脸验证(face verification)和人脸识别(face recognition)
这是一系列深度学习的介绍,本文不会涉及公式推导,主要是一些算法思想的随笔记录. 适用人群:深度学习初学者,转AI的开发人员. 编程语言:Python 参考资料:吴恩达老师的深度学习系列视频 吴恩达老师 ...
- 基于Face++使用python+opencv来实现人脸验证及人脸解锁
csdn不方便的话转到github 源码和图片资料都在github https://github.com/ChenJian-Jia/Based-on-face-Python-and-OpenCV-ar ...
- 虹软java接摄像头_虹软人脸识别SDK在网络摄像头中的实际应用
目前在人脸识别领域中,网络摄像头的使用很普遍,但接入网络摄像头和人脸识别SDK有一定门槛,在此篇中介绍过虹软人脸识别SDK的接入流程,本文着重介绍网络摄像头获取视频流并处理的流程(红色框内),以下内容 ...
- 基于Python下的OpenCv人脸检测
基于Python下的OpenCv人脸识别模拟 1.Pycharm下OpenCv的安装 2.人脸识别的原理 目标实现 基本原理 3.代码实现: 实现步骤 参考示意图: 1.Pycharm下OpenCv的 ...
- 基于虹软人脸识别,实现超市人脸支付
前言 随着计算机和网络技术的不断发达,人脸识别在我们的生活中也不断的被应用,而无人超市以及在超市中的人脸支付并没有普及,本文作为一个项目进行超市人脸支付的场景测试与探索. 实现功能 使用python语 ...
- 虹软人脸识别-SpringBoot集成
一.前言 人工智能时代的到来,相信大家已耳濡目染,虹软免费,离线开放的人脸识别 SDK,正推动着全行业进入刷脸时代.为了方便开发者接入,虹软提供了多种语言,多种平台的人脸识别SDK的支持,使用场景广泛 ...
最新文章
- HEOI 2012 旅行问题
- 有什么类型的MPLS?
- Introduction to Algorithm 6.3-3[Second Version]
- python中nltk_python2.7和NLTK安装详细教程
- [JAVA基础] 了解构造器Constructor———你真的会用构造器吗?
- 超级酒吧女生Java下载_超真实分享:一个人去酒吧的经验+注意事项
- GDCM:处理(各种操作处理)DICOM图像文件的测试程序
- java数组二分查找的简单例题_Java基础-练习 数组元素二分查找(折半查找)
- 443. 压缩字符串
- Oracle 游标范例
- 【OpenCV 例程200篇】15. 图像的加权加法(cv2.addWeight)
- api-ms-win-crt-runtime-l1-1-0.dll和api-ms-win-downlevel-shlwapi-l1-1-0.dll免费下载
- 线性表—顺序表-顺序表基本运算的实现
- Nginx+ffmpeg的HLS开源server搭建配置及开发具体解释
- 吉米多维奇数学分析习题集每日一题--泰勒公式习题1376
- 从架构到监控报警,支付系统的设计如何步步为营
- 亲密接触Redis-第一天
- 解决许可证的相关问题
- 今天电脑突然出现问题: 请安装 TCP/IP 协议 错误 10106 【已解决·】
- 紧急通知,1秒下达给员工 | 巴别鸟 V5.0上线