资源简介
这是我用C#写的摄像头控件,可以预览,拍照。
把项目添加到解决方案中,然后新建一个窗体,从工具箱中把CameraView控件拖到窗体上,再写一句:CameraView1.Start() 就启动了。
要拍照,请调用:cameraView1.TakePicture(filename);
本人心血啊!
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DirectShowLib;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.Threading;
using System.Diagnostics;
namespace CameraLib
{
[Guid(“A264F504-DE24-4fda-A27C-C319F7593C2C“)]
public partial class CameraView : UserControl
{
public CameraView()
{
InitializeComponent();
m_state = CameraState.Stop;
Enabled = false;
}
private void CameraView_Load(object sender EventArgs e)
{
Control topcontrol = Parent;
while (topcontrol != null)
{
if (topcontrol is Form)
{
Form fm = topcontrol as Form;
fm.FormClosed += new FormClosedEventHandler(fm_FormClosed);
break;
}
topcontrol = topcontrol.Parent;
}
}
void fm_FormClosed(object sender FormClosedEventArgs e)
{
Stop();
}
Thread eventthread;
MyCapture cam = null;
bool maincamera = true;
[Category(“CAMERA“)]
[Description(“是否使用主摄像头“)]
[DefaultValue(true)]
public bool MainCamera { get { return maincamera; } set { maincamera = value; } }
int width = 320;
[Category(“CAMERA“)]
[Description(“截图宽度“)]
[DefaultValue(320)]
public int PictureWidth { get { return width; } set { width = value; } }
int height = 240;
[Category(“CAMERA“)]
[Description(“截图高度“)]
[DefaultValue(240)]
public int PictureHeight { get { return height; } set { height = value; } }
CameraState m_state;
[Category(“CAMERA“)]
[Description(“运行状态“)]
public CameraState State
{
get { return m_state; }
private set
{
if (m_state != value)
{
m_state = value;
if (onStateChanged != null)
{
MethodInvoker mi = delegate()
{
onStateChanged(m_state);
};
if (Parent.InvokeRequired)
Parent.Invoke(mi);
else
mi();
}
}
}
}
public enum CameraState
{
Stop Run
}
public delegate void StateHandler(CameraState state);
[Category(“CAMERA“)]
[Description(“状态变化事件“)]
public event StateHandler onStateChanged = null;
public List sizes
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-04-13 21:10 CameraLib\bin\
目录 0 2013-04-13 21:11 CameraLib\bin\Debug\
文件 19968 2013-04-13 21:11 CameraLib\bin\Debug\CameraLib.dll
文件 52736 2013-04-13 21:11 CameraLib\bin\Debug\CameraLib.pdb
文件 282624 2013-03-29 16:37 CameraLib\bin\Debug\DirectShowLib-2005.dll
目录 0 2013-04-13 21:10 CameraLib\bin\x86\
目录 0 2013-04-10 18:26 CameraLib\bin\x86\Debug\
文件 19968 2013-04-03 16:49 CameraLib\bin\x86\Debug\CameraLib.dll
文件 44544 2013-04-03 16:49 CameraLib\bin\x86\Debug\CameraLib.pdb
文件 282624 2013-03-29 16:37 CameraLib\bin\x86\Debug\DirectShowLib.dll
文件 4053 2013-04-13 21:11 CameraLib\CameraLib.csproj
文件 168 2013-04-04 00:57 CameraLib\CameraLib.csproj.user
文件 7216 2013-04-04 01:08 CameraLib\CameraView.cs
文件 1588 2013-03-29 17:06 CameraLib\CameraView.Designer.cs
文件 5814 2013-03-29 17:06 CameraLib\CameraView.resx
文件 5051 2013-03-29 16:36 CameraLib\MyCamera.cs
文件 26276 2013-04-04 01:00 CameraLib\MyCapture.cs
目录 0 2013-04-10 18:26 CameraLib\obj\
目录 0 2013-04-13 21:11 CameraLib\obj\Debug\
文件 180 2013-04-13 21:11 CameraLib\obj\Debug\CameraLib.CameraView.resources
文件 2792 2013-04-13 21:11 CameraLib\obj\Debug\CameraLib.csproj.FileListAbsolute.txt
文件 779 2013-04-09 20:33 CameraLib\obj\Debug\CameraLib.csproj.GenerateResource.Cache
文件 19968 2013-04-13 21:11 CameraLib\obj\Debug\CameraLib.dll
文件 52736 2013-04-13 21:11 CameraLib\obj\Debug\CameraLib.pdb
目录 0 2013-04-10 19:04 CameraLib\obj\Debug\Refactor\
文件 8704 2013-04-10 19:04 CameraLib\obj\Debug\Refactor\CameraLib.dll
文件 6463 2013-04-13 21:11 CameraLib\obj\Debug\ResolveAssemblyReference.cache
目录 0 2013-03-29 16:36 CameraLib\obj\Debug\TempPE\
目录 0 2013-04-10 18:26 CameraLib\obj\x86\
目录 0 2013-04-10 18:26 CameraLib\obj\x86\Debug\
文件 180 2013-04-03 16:49 CameraLib\obj\x86\Debug\CameraLib.CameraView.resources
............此处省略11个文件信息
相关资源
- C#视频采集源码(视频技术)
- unity3d 连接外置摄像头
- C# onvif获取摄像头rtsp视频流地址和抓
- 海康威视荧石网络摄像头SDK开发C#De
- C#读取SD卡中采集摄像头数据
- C#生成和解析二维码及调用摄像头识别
- C#利用VFW实现摄像头程序
- MoveCamera.cs
- C#网络摄像头实现实时监控录像
- 在线拍照asp.net
- C#调用摄像头拍照录像保存
- WPF程序调用本机摄像头拍照
- asp.net 在线拍照
- ArcGlobeDemo
- vb.net调用高清摄像头实现拍照等功能
- C#操作Aforge摄像头 实现拍照功能
- C# winform调用本机摄像头,demo,
-
C#使用videoSourcePla
yer控件实现拍照录 - C#读取USB摄像头
- C#调用、操作usb摄像头
- C#下控制摄像头自动扫描识别二维码
- WPF使用Aforge实现USB摄像头拍照
- 海康威视摄像头调用asp.net版本C#语言
- C#Winform摄像头的视频录制和播放
- C#控制USB摄像头录像抓图
- camera
- DataMatrix DataMatrix(DM码)二维码编解码
- video C#摄像头视频获取及截图源代码
- camera C#操作USB摄像头
- test2 C#调用opencv打开摄像头录像
评论
共有 条评论