資源簡介
封裝了一個DLL,源碼在項目工程里,調用非常簡單方便
msxt = new mSheXiangTou(pictureBox1);
List temp = null;
if ((temp = msxt.GetVideoDevicesNameList) != null)
{
foreach (string str in temp)
{
comboBox1.Items.Add(str);
}
comboBox1.SelectedIndex = 0;
}
Open.Click += new EventHandler(Open_Click);
Close.Click += new EventHandler(msxt.Close_Click);
LuXiang.Click += new EventHandler(msxt.LuXiang_Click);
Stop.Click += new EventHandler(msxt.TingZhi_Click);
PaiZhao.Click += new EventHandler(msxt.PaiZhao_Click);
FormClosing += new FormClosingEventHandler(msxt.Form_FormClosing);
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Drawing;
using?System.Drawing.Imaging;
using?System.Windows.Forms;
using?AForge.Video.DirectShow;
using?AForge.Video;
using?AForge.Video.FFMPEG;
using?System.IO;
namespace?SheXiangTou
{
????public?class?mSheXiangTou
????{
????????public?List?GetVideoDevicesNameList
????????{
????????????get
????????????{
????????????????return?videoList;
????????????}
????????}
????????public?bool?SetShowTime
????????{
????????????set?{?isShowTime?=?value;?}
????????}
????????public?string?SetVideoSavePath
????????{
????????????set?{?videoSavePath?=?value;?}
????????}
????????public?string?SetPictureSavePath
????????{
????????????set?{?pictureSavePath?=?value;?}
????????}
????????public?int?GetframesReceived
????????{
????????????get?{?return?videoSource.framesReceived;?}
????????}
????????private?FilterInfoCollection?videoDevices;
????????private?VideoFileWriter?writer?=?new?VideoFileWriter();
????????private?VideoCaptureDevice?videoSource?=?null;
????????private?System.Diagnostics.Stopwatch?timer?=?null;
????????private?Bitmap?bitmap;
????????private?Font?font?=?new?Font(“宋體“?20);
????????private?SolidBrush?sbrush?=?new?SolidBrush(Color.Yellow);
????????private?PointF?strpoint?=?new?PointF(10?10);
????????private?Graphics?g?=?null;
????????private?List?videoList?=?null;
????????private?bool?isOpen?=?false;
????????private?bool?isLuxiang?=?false;
????????private?bool?isPaizhao?=?false;
????????private?bool?isShowTime?=?false;
????????private?PictureBox?picture?=?null;
????????private?string?videoSavePath?=?“video\\“;
????????private?string?pictureSavePath?=?“picture\\“;
????????public?mSheXiangTou(PictureBox?pb)
????????{
????????????picture?=?pb;
????????????if?(picture?==?null)
????????????{
????????????????throw?new?Exception(“傳入的PictureBox類型參數(shù)是NULL“);
????????????}
????????????GetVideo();
????????????CheckPath();
????????}
????????///?
????????///?檢查路徑
????????///?
????????private?void?CheckPath()
????????{
????????????DirectoryInfo?fInfo?=?null;
????????????fInfo?=?new?DirectoryInfo(videoSavePath);
????????????if?(!fInfo.Exists)
????????????{
????????????????Directory.CreateDirectory(videoSavePath);
????????????}
????????????fInfo?=?new?DirectoryInfo(pictureSavePath);
????????????if?(!fInfo.Exists)
????????????{
????????????????Directory.CreateDirectory(pictureSavePath);
????????????}
????????}
????????///?
????????///?獲得攝像頭設備
????????///?
????????public?void?GetVideo()
????????{
????????????try
????????????{
????????????????videoDevices?=?new?FilterInfoCollection(FilterCategory.VideoInputDevice);
????????????????if?(videoDevices.Count?==?0)
????????????????{
????????????????????MessageBox.Show(“沒有發(fā)現(xiàn)任何攝像頭設備“);
????????????????????return;
????????????????}
????????????????videoList?=?null;
????????????????videoL
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7680??2015-05-22?00:17??SheXiangTouTest\SheXiangTou\bin\Debug\SheXiangTou.dll
?????文件??????15872??2015-05-22?00:17??SheXiangTouTest\SheXiangTou\bin\Debug\SheXiangTou.pdb
?????文件???????7032??2015-05-22?22:42??SheXiangTouTest\SheXiangTou\mSheXiangTou.cs
?????文件???????5466??2015-07-23?22:20??SheXiangTouTest\SheXiangTou\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????3780??2015-05-22?22:36??SheXiangTouTest\SheXiangTou\obj\Debug\ResolveAssemblyReference.cache
?????文件????????971??2015-05-22?00:56??SheXiangTouTest\SheXiangTou\obj\Debug\SheXiangTou.csproj.FileListAbsolute.txt
?????文件???????8704??2015-05-22?22:44??SheXiangTouTest\SheXiangTou\obj\Debug\SheXiangTou.dll
?????文件??????17920??2015-05-22?22:44??SheXiangTouTest\SheXiangTou\obj\Debug\SheXiangTou.pdb
?????文件???????1372??2015-05-21?23:39??SheXiangTouTest\SheXiangTou\Properties\AssemblyInfo.cs
?????文件??????17408??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\AForge.dll
?????文件??????57856??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\AForge.Video.DirectShow.dll
?????文件??????18944??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\AForge.Video.dll
?????文件??????61952??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\AForge.Video.FFMPEG.dll
?????文件???13496832??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\avcodec-53.dll
?????文件?????349696??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\avdevice-53.dll
?????文件?????890880??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\avfilter-2.dll
?????文件????2462208??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\avformat-53.dll
?????文件?????137728??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\avutil-51.dll
?????文件?????296960??2013-03-26?10:41??SheXiangTouTest\SheXiangTou\refs\swscale-2.dll
?????文件???????2418??2015-05-22?00:56??SheXiangTouTest\SheXiangTou\SheXiangTou.csproj
?????文件??????17408??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\AForge.dll
?????文件??????57856??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\AForge.Video.DirectShow.dll
?????文件??????18944??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\AForge.Video.dll
?????文件??????61952??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\AForge.Video.FFMPEG.dll
?????文件???13496832??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\avcodec-53.dll
?????文件?????349696??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\avdevice-53.dll
?????文件?????890880??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\avfilter-2.dll
?????文件????2462208??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\avformat-53.dll
?????文件?????137728??2013-03-26?10:41??SheXiangTouTest\SheXiangTouTest\bin\Debug\avutil-51.dll
?????文件???????8704??2015-05-22?22:44??SheXiangTouTest\SheXiangTouTest\bin\Debug\SheXiangTou.dll
............此處省略50個文件信息
- 上一篇:C#萬能視頻播放器
- 下一篇:iis6.0 完整安裝包包括所需的Exe
評論
共有 條評論