Aforge的一点简单应用
2016-08-02 21:33
176 查看
今天正好需要将一些无标识的图片按照甲方给的编号将图片命名,我了个去,2340张,2340张啊!!!还是无偿的啊。。。。。心中无数只草尼草呼啸而过。。真是上面运动嘴,下面跑断腿啊。。啥也别说了,整吧。。要不不能怎么着。说实话,以前的项目也没有图片处理的经验,百度上神游一圈,别说,还真有点眉目了。四下对此下来,一个叫AForge的控件还挺对胃口的。再一圈参考下来,打开VS2008,洗个澡,let's go !
首先添加一些引用:
using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Imaging;
using AForge.Imaging.Filters;
然后新建一个选项卡(千万别告诉我不会 - -!),然后把Aforge.Controls.dll拖放在上面,会出现几个工具,如下图所示:
将VideoSourcePlayer控件拖放在form上,出会现控件区域。
然后该coding了,在form_load中整代码如下:
private void Form1_Load(object sender, EventArgs e)
{
count = 1;
//枚举所有视频输入设备
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
{
MessageBox.Show("未发现视频设备!");
return;
}
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
videoSource.DesiredFrameSize = new Size(800, 600);
videoSource.DesiredFrameRate = 1;
videoSourcePlayer1.VideoSource = videoSource;
}
先枚举视频设备,并定义大小和帧数。
然后打开摄像头:
videoSourcePlayer1.Start();
然后在videoSourcePlayer事件中找到NewFrame事件并双击:
在里面编辑代码如下:
Bitmap bitMap = image;
bitMap.Save(@"D:\" + textBox1.Text.Trim() + "_" + count.ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
//如果没有下面这行代码,将连续拍照,此行代码关键!!!!
videoSourcePlayer1.NewFrame -= new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer1_NewFrame);
然后在拍照按钮中代码如下:
注册这个事件,
videoSourcePlayer1.NewFrame +=new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer1_NewFrame);
基本代码就完成了,但是有个坑一直没有解决,望哪位大量指点,这个坑是:
一打开视频自动就会照一张图片是为什么呢??求解决啊求解决!
海纳百川,有容乃大;壁立千仞,无欲则钢!
测试代码链接:http://download.csdn.net/my/uploads
首先添加一些引用:
using AForge;
using AForge.Controls;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Imaging;
using AForge.Imaging.Filters;
然后新建一个选项卡(千万别告诉我不会 - -!),然后把Aforge.Controls.dll拖放在上面,会出现几个工具,如下图所示:
将VideoSourcePlayer控件拖放在form上,出会现控件区域。
然后该coding了,在form_load中整代码如下:
private void Form1_Load(object sender, EventArgs e)
{
count = 1;
//枚举所有视频输入设备
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if (videoDevices.Count == 0)
{
MessageBox.Show("未发现视频设备!");
return;
}
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
videoSource.DesiredFrameSize = new Size(800, 600);
videoSource.DesiredFrameRate = 1;
videoSourcePlayer1.VideoSource = videoSource;
}
先枚举视频设备,并定义大小和帧数。
然后打开摄像头:
videoSourcePlayer1.Start();
然后在videoSourcePlayer事件中找到NewFrame事件并双击:
在里面编辑代码如下:
Bitmap bitMap = image;
bitMap.Save(@"D:\" + textBox1.Text.Trim() + "_" + count.ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
//如果没有下面这行代码,将连续拍照,此行代码关键!!!!
videoSourcePlayer1.NewFrame -= new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer1_NewFrame);
然后在拍照按钮中代码如下:
注册这个事件,
videoSourcePlayer1.NewFrame +=new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer1_NewFrame);
基本代码就完成了,但是有个坑一直没有解决,望哪位大量指点,这个坑是:
一打开视频自动就会照一张图片是为什么呢??求解决啊求解决!
海纳百川,有容乃大;壁立千仞,无欲则钢!
测试代码链接:http://download.csdn.net/my/uploads
相关文章推荐
- winform程序之人员选择listbox控件应用了一点arraylist(简单)
- 简单JSF举例来介绍JSF应用及此MVC框架的一点好处
- 关于DataRow和DataColumn的一点个人简单理解-.NET教程,数据库应用
- 一个简单的表单(应用到一点HTML5)
- winform程序之录入删除显示人员应用了一点arraylist(简单)
- process类的简单应用
- Tomcat4/5连接池的设置及简单应用示例
- SQLSERVER扩展存储过程XP_CMDSHELL的简单应用
- java(j2ee)应用-简单自定义标签开发全过程----之一(Inber)——JAVA夜未眠
- Tomcat4/5连接池的设置及简单应用示例
- 简单dll动态链接库的建立和应用
- 关于DataRow和DataColumn的一点个人简单理解
- 使用C#开发一个简单的P2P应用
- Tomcat4/5连接池的设置及简单应用示例
- ORACLE触发器的一点应用 [转]
- [原创]用jar命令将Web应用打包成war文件的简单方法
- HTA的简单应用
- EJB之无状态会话Bean简单应用-学习与实践(Inber原作)
- 线程池在web上的简单应用