资源简介
AForge摄像头功能源码

代码片段和文件信息
using AForge.Video.DirectShow;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace AforgeDemo
{
public partial class Form1 : Form
{
private FilterInfoCollection videoDevices;//所有摄像设备
private VideoCaptureDevice videoDevice;//摄像设备
private VideoCapabilities[] videoCapabilities;//摄像头分辨率
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);//得到机器所有接入的摄像设备
if (videoDevices.Count != 0)
{
foreach (FilterInfo device in videoDevices)
{
cboVideo.Items.Add(device.Name);//把摄像设备添加到摄像列表中
}
}
else
{
cboVideo.Items.Add(“没有找到摄像头“);
}
cboVideo.SelectedIndex = 0;//默认选择第一个
}
private void cboVideo_SelectedIndexChanged(object sender EventArgs e)
{
if (videoDevices.Count != 0)
{
//获取摄像头
videoDevice = new VideoCaptureDevice(videoDevices[cboVideo.SelectedIndex].MonikerString);
GetDeviceResolution(videoDevice);//获得摄像头的分辨率
}
}
//获得摄像头的分辨率
private void GetDeviceResolution(VideoCaptureDevice videoCaptureDevice)
{
cboResolution.Items.Clear();//清空列表
videoCapabilities = videoCaptureDevice.VideoCapabilities;//设备的摄像头分辨率数组
foreach (VideoCapabilities capabilty in videoCapabilities)
{
//把这个设备的所有分辨率添加到列表
cboResolution.Items.Add($“{capabilty.frameSize.Width} x {capabilty.frameSize.Height}“);
}
cboResolution.SelectedIndex = 0;//默认选择第一个
}
private void btnConnect_Click(object sender EventArgs e)
{
if (videoDevice != null)//如果摄像头不为空
{
if ((videoCapabilities != null) && (videoCapabilities.Length != 0))
{
videoDevice.VideoResolution = videoCapabilities[cboResolution.SelectedIndex];//摄像头分辨率
vispShoot.VideoSource = videoDevice;//把摄像头赋给控件
vispShoot.Start();//开启摄像头
EnableControlStatus(false);
}
}
}
//控件的显示切换
private void EnableControlStatus(bool status)
{
cboVideo.Enabled = status;
cboResolution.Enabled = status;
btnConnect.Enabled = status;
btnPic.Enabled = !status;
btnCut.Enabled = !status;
}
private void btnCut_Click(object sender EventArgs e)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5385 2019-02-27 14:18 AforgeDemo\AforgeDemo.csproj
文件 44544 2013-07-17 23:22 AforgeDemo\bin\Debug\AForge.Controls.dll
文件 66108 2013-07-17 23:22 AforgeDemo\bin\Debug\AForge.Controls.xm
文件 17920 2013-07-17 23:15 AforgeDemo\bin\Debug\AForge.dll
文件 262656 2013-07-17 23:19 AforgeDemo\bin\Debug\AForge.Imaging.dll
文件 944046 2013-07-17 23:19 AforgeDemo\bin\Debug\AForge.Imaging.xm
文件 68096 2013-07-17 23:17 AforgeDemo\bin\Debug\AForge.Math.dll
文件 270650 2013-07-17 23:17 AforgeDemo\bin\Debug\AForge.Math.xm
文件 61440 2013-07-17 23:20 AforgeDemo\bin\Debug\AForge.Video.DirectShow.dll
文件 195287 2013-07-17 23:20 AforgeDemo\bin\Debug\AForge.Video.DirectShow.xm
文件 20992 2013-07-17 23:20 AforgeDemo\bin\Debug\AForge.Video.dll
文件 53275 2013-07-17 23:20 AforgeDemo\bin\Debug\AForge.Video.xm
文件 78375 2013-07-17 23:15 AforgeDemo\bin\Debug\AForge.xm
文件 12288 2019-02-27 15:14 AforgeDemo\bin\Debug\AforgeDemo.exe
文件 24064 2019-02-27 15:14 AforgeDemo\bin\Debug\AforgeDemo.pdb
文件 22688 2019-02-27 15:01 AforgeDemo\bin\Debug\AforgeDemo.vshost.exe
文件 490 2015-10-22 09:54 AforgeDemo\bin\Debug\AforgeDemo.vshost.exe.manifest
文件 4138 2019-02-27 15:12 AforgeDemo\Form1.cs
文件 7413 2019-02-27 15:01 AforgeDemo\Form1.Designer.cs
文件 5817 2019-02-27 15:01 AforgeDemo\Form1.resx
文件 1361 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.csproj.FileListAbsolute.txt
文件 1012 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.csproj.GenerateResource.Cache
文件 12288 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.exe
文件 180 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.Form1.resources
文件 24064 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.pdb
文件 180 2019-02-27 15:14 AforgeDemo\obj\Debug\AforgeDemo.Properties.Resources.resources
文件 7428 2019-02-27 14:18 AforgeDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 513 2019-02-27 14:18 AforgeDemo\packages.config
文件 491 2019-02-27 14:16 AforgeDemo\Program.cs
文件 1346 2019-02-27 14:16 AforgeDemo\Properties\AssemblyInfo.cs
............此处省略14个文件信息
- 上一篇:vuejs 视频教程
- 下一篇:PCL1.8 vs2013 CMAKE源码编译教程
相关资源
- 安卓wifi直连app源码
- 我的世界源码(易语言版)
- labview编程软件滤波器以及编写程序设
- 我的界面(visual foxpro)源码
- 易语言:一键cf基址源码
- The Secret Path 3D 3D魔方迷宫[源码][scra
- scratch垃圾分类源码(最终版本).sb
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- UNIX/LINUX编程实践教程的源码
- 十以内加减法练习 powerbuilder源码
- 农场开发项目
- OCR源码
- PLC上位机编程软件
- 用foobar2000听google音乐[更新一下]
- 学生信息管理系统源码
- 用VC 编写的仿QQ聊天室程序源代码
- 毕业论文之温度传感器DS18B20(源码
- 可自定义导航网站源码
- 栅栏填充算法源码(VC)
- msp430F149操作红外接收模块源码
- [免费]图像识别c 源码
- 周易排盘源码
- RSA算法源码
- 一个人脸识别程序源码
- 编译原理课程设计:词法语法编译器
- 透明加密源码及说明
- 电视直播源码
- 远程桌面(带C 源码)
评论
共有 条评论