AForge.NET专为计算机视觉和人工智能应用而设计,这种C#框架适用于图像处理、神经网络、遗传算法、模糊逻辑、机器学习和机器人等。

该库是一个开源项目,包括:

AForge.Imaging —— 一些日常的图像处理和过滤器
 AForge.Vision —— 计算机视觉应用类库
 AForge.Neuro —— 神经网络计算库AForge.Genetic -进化算法编程库
 AForge.MachineLearning —— 机器学习类库
 AForge.Robotics —— 提供一些机器人的工具类库
 AForge.Video —— 一系列的视频处理类库
 AForge.Fuzzy —— 模糊推理系统类库
 AForge.Controls—— 图像,三维,图表显示控件

具体见官网:http://www.aforgenet.com/

简单用法如下:

1、安装包:VS→工具→包管理器→输入关键字“AForge”→安装

2、获取本机摄像头、声卡设备列表

List<string> VideoList = GetVideoInDevicesList();
VideolistBox.DataSource = VideoList;List<string> AudioList = GetAudioInDevicesList();
AudiolistBox.DataSource = AudioList;/// <summary>
/// 获取摄像头列表
/// </summary>
/// <returns></returns>
public static List<string> GetVideoInDevicesList()
{List<string> devicesList = new List<string>();try{
var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo device in videoDevices)
{devicesList.Add(device.Name);
}}catch (Exception ex){
Console.WriteLine(ex.Message);}return devicesList;
}/// <summary>
/// 获取音频设备列表
/// </summary>
/// <returns></returns>
public static List<string> GetAudioInDevicesList()
{List<string> devicesList = new List<string>();try{
var videoDevices = new FilterInfoCollection(FilterCategory.AudioInputDevice);//输入设备
foreach (FilterInfo device in videoDevices)
{devicesList.Add(device.Name);
}}catch (ApplicationException){
Console.WriteLine("No local capture devices");}return devicesList;
}

运行结果:

3、打开摄像头显示内容:

var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
FilterInfo info = videoDevices[VideolistBox.SelectedIndex];var videoSource = new VideoCaptureDevice(info.MonikerString);
AForge.Controls.VideoSourcePlayer videoSourcePlayer1 = new AForge.Controls.VideoSourcePlayer();
videoSourcePlayer1.VideoSource = videoSource;
videoSourcePlayer1.Width = 1600;
videoSourcePlayer1.Height = 900;
this.Controls.Add(videoSourcePlayer1);
videoSourcePlayer1.Start();

4、调整分辨率

private void SetResolution()
{//分辨率调整至最高try{var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);FilterInfo info = videoDevices[VideolistBox.SelectedIndex];var videoSource = new VideoCaptureDevice(info.MonikerString);var formats = videoSource.VideoCapabilities;if (formats.Length > 1){videoSource.VideoResolution = formats[0];//默认第一个就是最高分辨率}}catch { }
}

5、调用摄像头参数面板

//摄像头参数设置
private void CamSetup()
{var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);FilterInfo info = videoDevices[VideolistBox.SelectedIndex];VideoCaptureDevice videoCaptureDevice = new VideoCaptureDevice(info.MonikerString);try{videoCaptureDevice.DisplayPropertyPage(this.Handle);}catch {MessageBox.Show("所选视频设备不支持设置页面","出错",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1);}}

6、画面的放大、平移

方法:

详见:http://www.aforgenet.com/framework/docs/html/077a7afb-c9bd-91b6-6870-61440e2f4060.htm

public bool SetCameraProperty(CameraControlProperty property,int value,CameraControlFlags controlFlags
)

其中:property

Pan 水平移动(放大后)-16 至 +16
Tilt 垂直移动(放大后)-16 至 +16
Roll 旋转 0 至 3
Zoom 缩放 100 至 400
Exposure 曝光 -12 至 -3
Iris 红外灯
Focus 聚焦

value:Int32数字

controlFlags:

None(No control flag.)
Auto (自动)
Manual (手工)

实例:

var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
FilterInfo info = videoDevices[VideolistBox.SelectedIndex];VideoCaptureDevice videoCaptureDevice = new VideoCaptureDevice(info.MonikerString);
try
{videoCaptureDevice.SetCameraProperty(CameraControlProperty.Zoom, 400, CameraControlFlags.Manual);
}
catch
{MessageBox.Show("所选视频设备不支持","出错",MessageBoxButtons.OK,MessageBoxIcon.Error,MessageBoxDefaultButton.Button1);
}

参考:

C# AForge的简单使用相关推荐

  1. aforge 相机标定_C#调用本地摄像头-AForge库简单使用

    介绍 用途 调用笔记本电脑自带的相机 示例 源码 using System; using System.Collections.Generic; using System.ComponentModel ...

  2. 基于Aforge的手势识别之一~~~简单的手写识别

    本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处! 上一篇文章介绍了如何用Aforge去捕捉运动物体,现在就介绍一个更深入的操作----手势识别.       我 ...

  3. c#屏幕录制(经典)(含源码和AForge.Video.FFMPEG.DLL)及填坑办法

    一直觉得.net在多媒体处理方面渣得不行.最近需要做一个摄像头的程序,为了方便,用了AForge这个开源项目.AForge项目中有AForge.Video和AForge.Video. DirectSh ...

  4. 基于AForge.Net框架的扑克牌识别(Nazmi Altun著,野比 译)

    © 版权所有 野比 2012 原文地址:点击查看 作者:Nazmi Altun  下载源代码 - 148.61 KB  下载demo - 3.1 MB 介绍 (图片上的字:方块4,方块J,黑桃2) 用 ...

  5. Aforge做图像处理

    Emgucv (用c#调用 sharp版 opencv)中的函数,会引起内存泄漏(如下语句),所以改用Aforge实现 Bitmap bmp = new Bitmap("D:\\4.png& ...

  6. AForge学习笔记(3):AForge.Fuzzy

    AForge.Fuzzy 提供了大量的模糊集操作. FuzzySet:模糊集是模糊应用的基础,也是理解模糊应用的关键,我们通过一个例子理解模糊集的概念:在现实生活中我们以冷暖来直观的描述温度,例如我们 ...

  7. AForge学习笔记(4):AForge.Genetic

    遗传算法简介: 在学习AForge的遗传算法之前,我们首先简单介绍一下遗传算法的理念:遗传算法的提出是源于达尔文进化论思想的启发,优胜劣汰,适者生存,适应力强的生存下去的几率更大,那么在算法上我们用适 ...

  8. AForge学习笔记(5):AForge.Imaging(上)

    作者:GAO-XIANG 转自:http://blog.csdn.net/xiang__jiangsu/article/details/8131141 本次我们一起来学习AForge中影像处理算法以及 ...

  9. 基于AForge的C#摄像头视频录制

    1. 概述 最近搞华为的CDN(-_-||-_-||-_-||),写东西的时间比较少了.最近由于兴趣学习了下在C#上使用AForge录制摄像头视频并压缩编码.总体上来说这个第三方.net视觉开发库还是 ...

最新文章

  1. iPhone遭遇最强烈的黑客攻击:密码、位置、联系人,敏感数据都泄露,谷歌发现的...
  2. NodeJS优缺点及适用场景讨论
  3. MySql分表、分库、分片和分区的区别
  4. 2017202110104-高级软件工程2017第8次作业—个人总结
  5. 1138 Postorder Traversal (25 分)【难度: 一般 / 知识点: 建树】
  6. oracle 00980,ORA-00980如何解决
  7. 最流行的python爬虫框架_Python最火爬虫框架Scrapy入门与实践
  8. 方舟编译器开源技术沙龙北京站首秀:让开源激活软件开发的潜力
  9. 《信息处理技术员考试考前冲刺预测卷及考点解析》下午案例复习重点
  10. L298N模块驱动电机(实现pwm调速)
  11. 酒店管理系统c语言课程设计,基于C语言的酒店管理系统课程设计.doc
  12. VoLTE业务端到端流程:EPC侧信令流程
  13. CS1.6自定义游戏中的H菜单和设置菜单,增加一键买枪功能
  14. 存储容量及相关计算单位
  15. 供应商网店货源哪里找?直播带货靠谱货源(电商教程)
  16. 反弹中快速获利的操盘技巧
  17. Java基础语法-环境搭建及入门
  18. 网站服务器如何选择?
  19. JDBC连接mysql遇到的问题
  20. 深夜爬虫, 我很抱歉 , 附微信 “ 网抑云” 公众号爬虫教程!

热门文章

  1. 路径搜索算法——RRT算法
  2. 【物理应用】基于傅里叶伽辽金谱法二维纳维-斯托克斯附matlab代码
  3. 4123版驱动最新支持《霍格沃茨之遗》,英特尔锐炫显卡带你畅游魔法世界
  4. Vijos 捕风捉影
  5. 搭建邮件服务器 提示554 DT:SPM 163
  6. php文本编辑器fck,HTML文本编辑器:FCKeditor 2.6.3下载
  7. 网络工程师经典技术面试题系列华为数通 STP关键理论与实战
  8. 异速联集中部署与管理解决方案
  9. 使用C#开发Word VSTO外接程序示例
  10. 今日头条信息流 - 创意设置详解