人脸检测源码facedetection

人脸检测源码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AForge;
using AForge.Controls;
using AForge.Imaging;
using AForge.Video;
using AForge.Video.DirectShow;
using face;namespace Camtest
{public partial class facedetection : Form{/// <summary>/// 人脸检测/// </summary>public facedetection(){InitializeComponent();//启动默认在屏幕中间this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;}FilterInfoCollection videoDevices;VideoCaptureDevice videoSource;public int selectedDeviceIndex = 0;public int selectedPICIndex = 0;/// <summary>/// 加载窗体/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void Form1_Load(object sender, EventArgs e){// 刷新可用相机的列表videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);comboBoxCameras.Items.Clear();for (int i = 0; i < videoDevices.Count; i++){comboBoxCameras.Items.Add(videoDevices[i].Name.ToString());}if (comboBoxCameras.Items.Count > 0)comboBoxCameras.SelectedIndex = 0;picsize.SelectedIndex = 0;this.label4.Text = this.label5.Text = this.label7.Text = this.label9.Text = this.label11.Text = this.label13.Text = "正在识别";this.label4.ForeColor = Color.Red;this.label5.ForeColor = Color.Red;this.label7.ForeColor = Color.Red;this.label9.ForeColor = Color.Red;this.label11.ForeColor = Color.Red;this.label13.ForeColor = Color.Red;openCan();}//关闭窗体private void Form1_FormClosing(object sender, FormClosingEventArgs e){DialogResult r = MessageBox.Show("确定要退出程序?", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);if (r != DialogResult.OK){e.Cancel = true;}videoSourcePlayer1.Stop();//停止摄像头videoSourcePlayer1.Dispose();}//实时显示照片private void videoSourcePlayer1_Click(object sender, EventArgs e){}/// <summary>/// 打开摄像头/// </summary>public void openCan(){selectedPICIndex = picsize.SelectedIndex;selectedDeviceIndex = comboBoxCameras.SelectedIndex;//连接摄像头。videoSource = new VideoCaptureDevice(videoDevices[selectedDeviceIndex].MonikerString);videoSource.VideoResolution = videoSource.VideoCapabilities[selectedDeviceIndex];// 枚举所有摄像头支持的像素,设置拍照为1920*1080foreach (VideoCapabilities capab in videoSource.VideoCapabilities){if (selectedPICIndex == 0){if (capab.FrameSize.Width == 1920 && capab.FrameSize.Height == 1080){videoSource.VideoResolution = capab;break;}if (capab.FrameSize.Width == 1280 && capab.FrameSize.Height == 720){videoSource.VideoResolution = capab;break;}}else{if (capab.FrameSize.Width == 1280 && capab.FrameSize.Height == 720){videoSource.VideoResolution = capab;break;}}}videoSourcePlayer1.VideoSource = videoSource;// set NewFrame event handlervideoSourcePlayer1.Start();}//保存图片private void button2_Click(object sender, EventArgs e){if (videoSource == null)return;Bitmap bitmap = videoSourcePlayer1.GetCurrentVideoFrame();//图片名称,年月日时分秒毫秒.jpgstring fileName = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".jpg";//获取项目的根目录String path = AppDomain.CurrentDomain.BaseDirectory;//将图片保存在服务器里面bitmap.Save(path + "\\picture\\" + fileName, ImageFormat.Jpeg);bitmap.Dispose();//进行面部特征识别facemodel facem = face_test.FaceDetect(path + "\\picture\\" + fileName);this.label4.Text = facem.age;      //年龄this.label5.Text = facem.beauty;  //漂亮度string expression = facem.expression;//表情if (expression.Equals("0")){this.label7.Text = "不笑";}else if (expression.Equals("1")){this.label7.Text = "微笑";}else if (expression.Equals("2")){this.label7.Text = "大笑";}string gender = facem.gender;//性别if (gender.Equals("male")){this.label9.Text = "男";}else{this.label9.Text = "女";}string glasses = facem.glasses;//是否戴眼镜if (glasses.Equals("0")){this.label11.Text = "无眼镜";}else if (glasses.Equals("1")){this.label11.Text = "普通眼镜";}else{this.label11.Text = "墨镜";}string race = facem.race;//人种if (race.Equals("yellow")){this.label13.Text = "黄人";}else if (race.Equals("white")){this.label13.Text = "白人";}else if (race.Equals("black")){this.label13.Text = "黑人";}else if (race.Equals("arabs")){this.label13.Text = "棕人";}}//取消的按钮private void close_Click(object sender, EventArgs e){//停止摄像头videoSourcePlayer1.Stop();this.Close();welcome we = new welcome();we.Show();}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/326903.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

73. 矩阵置零---LeetCode---JAVA

代码实现 class Solution {public void setZeroes(int[][] matrix) {boolean[] xnew boolean[matrix.length];boolean[] ynew boolean[matrix[0].length];for(int i0;i<matrix.length;i){for(int j0;j<matrix[0].length;j){if(matrix[i][j]0){x[i]true;y[j]true; …

真正理解线程上下文类加载器(多案例分析)

转载自 真正理解线程上下文类加载器&#xff08;多案例分析&#xff09; 前置知识&#xff1a; java类加载器不完整分析 前言 此前我对线程上下文类加载器&#xff08;ThreadContextClassLoader&#xff0c;下文使用TCCL表示&#xff09;的理解仅仅局限于下面这段话&#x…

Docker4Dev #6 使用 Windows Container 运行.net应用

关于d4d系列&#xff1a;之前这个系列叫做docker4dotnet&#xff0c;因为当时主要是为了能够探索在docker上运行.net应用&#xff1b;现在我觉得应该叫做docker4developer&#xff0c;因为我希望能够帮助更多的开发人员使用docker技术。今天这篇就算是新的Docker4Dev系列的开始…

jquery对象和DOM对象的相互转换详解

jquery对象和DOM对象的相互转换 在讨论jquery对象和DOM对象的相互转换之前&#xff0c;先约定好定义变量的风格如果获取的是jquery对象&#xff0c;那么在变量前面加上$,例如 var $varible jquery对象&#xff1b; 如果获取的是DOM对象&#xff0c;则定义如下&#xff1a; …

人脸注册源码faceregiste

人脸注册&#xff1a; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AForge; using …

LC67---删除有序链表中重复的元素---牛客---JAVA

import java.util.*;/** public class ListNode {* int val;* ListNode next null;* }*/public class Solution {/*** * param head ListNode类 * return ListNode类*/public ListNode deleteDuplicates (ListNode head) {if(headnull)return head;ListNode temp head;wh…

破坏双亲委派机制的那些事

转载自 破坏双亲委派机制的那些事 前言 今天重读《深入理解Java虚拟》这本书&#xff0c;读到破坏双亲委派机制这一小节&#xff0c;其中有一段话&#xff0c;如下 双亲委派模型的第二次“被破坏”是由这个模型自身的缺陷所导致的&#xff0c;双亲委派很好地解决了各个类加…

Windows 容器

什么是容器 它们是隔离、资源控制且可移植的操作环境。 基本上&#xff0c;容器是一个隔离的位置&#xff0c;应用程序可在其中运行&#xff0c;而不会影响系统的其他部分&#xff0c;并且系统也不会影响该应用程序。 容器是虚拟化的下一个演化。 如果你在容器内&#xff0c;看…

人脸认证源码faceIdentify

人脸认证&#xff1a; using AForge.Video.DirectShow; using face; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Dr…

选择排序+推导过程

图解 代码实现 package com.atguigu.sort;import java.util.Arrays; import java.util.List;/*** 创建人 wdl* 创建时间 2021/3/21* 描述*/ public class SelectSort {public static void main(String[] args) {int []arr{101,34,119,1};System.out.println("排序前"…

Echart折线图 柱状图

echat_百度搜索 Examples - Apache ECharts Examples - Apache ECharts Examples - Apache ECharts 修改左侧的数据 点击右侧下载可以得到html页面 Examples - Apache ECharts Examples - Apache ECharts

Streaming的算法Reservoir Sampling

转载自 这是一个惊艳了我的算法题 Reservoir Sampling( Reservoir sampling ) 这是我在今年求职过程中面试的时候被问到的&#xff0c;因为之前很少接触Streaming的算法&#xff0c;在听到这个题目的时候被惊呆了&#xff0c;根本不能理解&#xff1a; 给一个Streaming…

软件定义数据中心—Windows Server SDDC技术与实践

《软件定义数据中心—Windows Server SDDC技术与实践》是国内第一本讲解微软Windows Server 软件定义数据中心的中文图书&#xff0c;书中系统、全面地介绍了微软Windows Server 软件定义数据中心各个模块&#xff08;SDS/SDN/SDC/容器&#xff09;的概念、技术和架构&#xff…

人脸登陆facelogin

人脸登陆&#xff1a; using AForge.Video.DirectShow; using face; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Dr…

插入排序+思路分析

图解 代码实现 package com.atguigu.sort;import java.util.Arrays;/*** 创建人 wdl* 创建时间 2021/3/22* 描述*/ public class InsertSort {public static void main(String[] args) {int[] arr{101,34,119,1};insertSort(arr);}//插入排序public static void insertSort(in…

.NET 十五岁,谈谈我眼中的.NET

2002年2月13日&#xff0c;第一个版本随着visual studio.net的发布&#xff0c;今天已经走过15年, .net团队写了一篇文章&#xff0c;里面有一个视频&#xff0c;Anders Hejlsberg已是白发苍苍的老人&#xff0c;我也从刚出校门的码农长成软件开发工程师&#xff0c;我爱编程。…

中国朝代及首都

朝 代 起 讫 都 城 今 地 夏 约前2146-1675年 安邑 山西夏县 ①商 约前1675-1029年 亳 河南商丘 周 西周 ②约前1029-771年 镐京 陕西西安 东周 前770-256年 洛邑 河南洛阳 秦 前221-207年 咸阳 陕西咸阳 汉 ③西汉 前206—公元25 长安 陕西西安 东汉 25—220 洛阳 河南洛阳 三…

什么注解可以改变BigDecimal类型的字段返回的小数位数?

什么注解可以改变BigDecimal类型的字段返回的小数位数&#xff1f;_myme95的博客-CSDN博客 问题背景&#xff1a;我在数据库里有一个字段&#xff0c;是decimal(20,15)类型&#xff0c;但是我在代码里返回数据给前端时&#xff0c;我要返回5位小数给前端。那么怎么转换BigDecim…

ThreadLocal的非数据安全用法

启发于同学处理的bug&#xff0c;他遇到的问题是&#xff1a; “有三台Tomcat服务器&#xff0c;其中有一台Tomcat服务器出现这种情况&#xff1a;一个用户A登录了系统&#xff0c;如果有新的用户B接着登录系统&#xff0c;会把用户A的登录信息给替换成新用户B的信息。这造成无…

理解并从头搭建redis集群

部分开发人员工作当中只是在应用中使用redis&#xff0c;比如用来做数据结果的缓存。而且现在有很多不错的redis客户端工具(redisson)&#xff0c;基本上可以不用关注redis命令就可以完成相当部分的功能。所以可能会对如下这些问题关注点不够&#xff1a; 如何容灾&#xff1f;…