资源简介
此程序是基于AForge库开发的调用USB摄像头进行录像和图片抓拍功能demo,希望对不熟悉此库的开发人员有所借鉴和帮助。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing.Imaging;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.IO;
using System.Windows.Media.Imaging;
using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using System.Timers;
using System.Runtime.InteropServices;
using System.Drawing;
using AForge.Video.FFMPEG;
namespace OperateCamera
{
public partial class Form1 : Form
{
private FilterInfoCollection videoDevices;
private VideoCaptureDevice videoSource;
private delegate void WriteLabelDelegate(object entry);
private bool stopREC = true;
private bool createNewFile = true;
int frameRate = 25; //默认帧率
private VideoFileWriter videoWriter = null;
private string videoFileFullPath = string.Empty; //视频文件全路径
private string imageFileFullPath = string.Empty; //图像文件全路径
private string videoPath = @“E:\video\“; //视频文件路径
private string videoFileName = string.Empty; //视频文件名
private string drawDate = string.Empty;
private VideoFileReader _reader;
private VideoFileWriter _writer;
static int intFlag = 0;
[DllImport(“gdi32“)]
static extern int Deleteobject(IntPtr o);
static System.Timers.Timer timerPic;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
try
{
// 枚举所有视频输入设备
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
throw new ApplicationException();
foreach (FilterInfo device in videoDevices)
{
tscbxCameras.Items.Add(device.Name);
}
tscbxCameras.SelectedIndex = 0;
}
catch (ApplicationException)
{
tscbxCameras.Items.Add(“没有找到摄像透“);
videoDevices = null;
}
}
private void btnConnect_Click(object sender EventArgs e)
{
CameraConn();
}
//连接摄像头
private void CameraConn()
{
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[tscbxCameras.SelectedIndex].MonikerString);
videoSource.DesiredframeSize = new System.Drawing.Size(320 240);
videoSource.DesiredframeRate = 1;
videoSourcePlayer.VideoSource = videoSource;
videoSourcePlayer.Start();
}
//关闭摄像头
private void btnClose_Click(object sender EventArgs e)
{
videoSourcePlayer.SignalToStop();
videoSourcePlayer.WaitFo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-07-05 13:54 OperateCamera\
文件 246 2015-07-04 15:30 OperateCamera\App.config
文件 11592 2015-07-04 23:29 OperateCamera\Form1.Designer.cs
文件 11386 2015-07-05 12:51 OperateCamera\Form1.cs
文件 6212 2015-07-04 23:29 OperateCamera\Form1.resx
文件 5543 2015-07-04 23:50 OperateCamera\OperateCamera.csproj
文件 227 2014-02-16 20:18 OperateCamera\OperateCamera.csproj.user
文件 867 2015-07-01 09:51 OperateCamera\OperateCamera.sln
文件 25088 2015-07-05 12:53 OperateCamera\OperateCamera.suo
文件 494 2014-02-16 17:21 OperateCamera\Program.cs
目录 0 2015-07-02 20:37 OperateCamera\Properties\
文件 1358 2014-02-16 17:21 OperateCamera\Properties\AssemblyInfo.cs
文件 2866 2015-07-04 23:50 OperateCamera\Properties\Resources.Designer.cs
文件 5612 2014-02-16 17:21 OperateCamera\Properties\Resources.resx
文件 1113 2015-07-04 23:50 OperateCamera\Properties\Settings.Designer.cs
文件 249 2014-02-16 17:21 OperateCamera\Properties\Settings.settings
目录 0 2015-07-05 13:55 OperateCamera\Service References\
文件 9187 2015-07-04 23:19 OperateCamera\VideoOperate.cs
目录 0 2015-07-05 13:54 OperateCamera\bin\
目录 0 2015-07-05 13:54 OperateCamera\bin\Debug\
文件 44544 2013-07-15 23:04 OperateCamera\bin\Debug\AForge.Controls.dll
文件 262656 2013-07-15 23:04 OperateCamera\bin\Debug\AForge.Imaging.dll
文件 61440 2013-07-15 23:04 OperateCamera\bin\Debug\AForge.Video.DirectShow.dll
文件 61952 2013-07-15 23:07 OperateCamera\bin\Debug\AForge.Video.FFMPEG.dll
文件 20992 2013-07-15 23:04 OperateCamera\bin\Debug\AForge.Video.dll
文件 17920 2013-07-15 23:04 OperateCamera\bin\Debug\AForge.dll
文件 20480 2015-07-05 12:51 OperateCamera\bin\Debug\OperateCamera.exe
文件 246 2015-07-04 15:30 OperateCamera\bin\Debug\OperateCamera.exe.config
文件 30208 2015-07-05 12:51 OperateCamera\bin\Debug\OperateCamera.pdb
文件 11608 2015-07-05 12:50 OperateCamera\bin\Debug\OperateCamera.vshost.exe
文件 246 2015-07-04 15:30 OperateCamera\bin\Debug\OperateCamera.vshost.exe.config
............此处省略51个文件信息
相关资源
- 深入理解c#(第3版) 中文版带书签
- C# 票务管理系统包含完整的源码、设
- Unity 5实战:使用C#和Unity开发多平台游
- c# 微信接口,包括小程序,企业微信
- wpf聊天小程序
- Essential C# 7.0 6th Edition.pdf
- Effective C#(covers C# 6.0).pdf
- ASP.NET的图书馆管理系统网站
- 基于asp.net mvc的开源网站管理系统
- FluentFTP已编译
- MapEditor地图的使用C#版
- C#桌面应用程序开发教程
- webkit.net 0.5版c#和winform嵌入chrome核心浏
- C#使用ModbusTcp协议与西门子1200PLC通讯
- asp.net 期末大作业
- C#制作KTV点歌系统,包括前台的点歌和
- 深入理解C#第三版英文版
- Asp.net MVC4高级程序设计Professional ASP
- sqlite-netFx40-setup-bundle-x86-2010-1.0.97.0.
- ARCGIS ENGINE+C#入门经典__赵银军
- C# OpenCvSharp打开摄像头
- c#会员管理系统源代码 淘宝购买
- ASP.NET WebForm通用权限系统框架源码 二
- 30天学通C#项目案例开发 完整版
- VS2012编译RTKLIB——GNSS定位开源库
- C# WinForm实践开发教程高清PDF带书签
- 基于vlc的c#开发视频播放器支持多种视
- 最新微信公众平台源码 C# ASP.NET 微商
- C# 网络课程管理系统源代码完全能运
- vue项目demoasp.net mvc5+vue2.5
评论
共有 条评论