c#如何捕获摄像头内容?
来源:互联网 发布:发现利润区 知乎 编辑:程序博客网 时间:2024/05/16 06:25
email这么多,在线解决.
在button的click事件中加入:(前提是你装有Media 编码器9)
// Create WMEncoderApp and WMEncoder objects.
WMEncoderApp EncoderApp = new WMEncoderApp();
IWMEncoder Encoder = EncoderApp.Encoder;
// Display the predefined Encoder UI.
EncoderApp.Visible =true;
// Specify the source for the input stream.
IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection;
IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1");
IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcAud.SetInput("Default_Audio_Device", "Device", "");
SrcVid.SetInput("Default_Video_Device", "Device", "");
// Specify a profile.
IWMEncProfile Pro;
IWMEncProfileCollection ProColl = Encoder.ProfileCollection;
for (int i = 0; i < ProColl.Count; i++)
{
Pro = ProColl.Item(i);
if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)")
{
SrcGrp.set_Profile(Pro);
break;
}
}
// Create a broadcast.
IWMEncBroadcast BrdCst = Encoder.Broadcast;
BrdCst.set_PortNumber (WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, 8080);
// Start the encoding process.
Encoder.PrepareToEncode(true);
Encoder.Start();Top
29 楼hunter4500(hunter4500)回复于 2003-07-18 15:34:10 得分 0
还有,引用中加上windows media encoder
代码前加上using WMEncoderLib;Top
多个摄像头的参考
int lPreviewStream;
string sDeviceString;
// Create a WMEncoder object.
Encoder = new WMEncoder();
// Retrieve a device control plug-in info manager object from WMEncoder.
DCPlugMgr = Encoder.DeviceControlPluginInfoManager;
// Loop through the connected digital devices on the system such as DV cameras and VTRs.
for (int i = 0; i < DCPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = DCPlugMgr.Item(i);
// Find the first device plug-in that support resources.
if (PlugInfo.SchemeType=="DeviceControl" && PlugInfo.Resources == true)
{
sDeviceString = PlugInfo.Item(0);
}
break;
}
// Add an audio source and a video source.
SrcGrpColl = Encoder.SourceGroupCollection;
SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add("SG_1");
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
SrcAud.SetInput(sDeviceString, "Device", "");
SrcVid.SetInput(sDeviceString, "Device", "");
参考2:
// Create a WMEncoder object.
WMEncoder Encoder = new WMEncoder();
// Retrieve source and device plug-in info manager objects from WMEncoder.
IWMEncSourcePluginInfoManager SrcPlugMgr = Encoder.SourcePluginInfoManager;
IWMEncDeviceControlPluginInfoManager DCPlugMgr = Encoder.DeviceControlPluginInfoManager;
// Loop through all the audio and video devices on the system.
IWMEncPluginInfo PlugInfo;
for (int i = 0; i < SrcPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = SrcPlugMgr.Item(i);
// Find the device plug-ins that support resources.
if (PlugInfo.SchemeType == "DEVICE" && PlugInfo.Resources == true)
{
// Loop through the resources in the current plug-in.
for (int j = 0; j<PlugInfo.Count; j++)
{
// Add audio resources to the cboAudioSource combo box.
if (PlugInfo.MediaType == WMENC_SOURCE_TYPE.WMENC_AUDIO) cboAudioSource.Items.Add(PlugInfo.Item(j));
// Add video resources to the cboVideoSource combo box.
if (PlugInfo.MediaType == WMENC_SOURCE_TYPE.WMENC_VIDEO) cboVideoSource.Items.Add(PlugInfo.Item(j));
}
}
}
// This section shows how to enumerate digital devices such as DV cameras and VTRs.
// Loop through the connected digital devices on the system.
for (int i = 0; i < DCPlugMgr.Count; i++)
{
// Set the IWMEncPluginInfo object to the current plug-in.
PlugInfo = DCPlugMgr.Item(i);
// Loop through the resources in the current plug-in
// and add them to the cboDevices combo box.
if (PlugInfo.SchemeType=="DeviceControl" && PlugInfo.Resources == true)
{
for (int j = 0; j< PlugInfo.Count; j++) cboDevices.Items.Add(PlugInfo.Item(j));
}
}
- c#如何捕获摄像头内容?
- C# 捕获摄像头图像
- 用C#捕获摄像头
- C# 捕获摄像头的每一帧图像
- 捕获摄像头
- C#捕获摄像头进行拍照和录像资料总结
- C#捕获摄像头进行拍照和录像资料总结
- C#捕获摄像头进行拍照和录像资料总结
- C#捕获摄像头进行拍照和录像资料总结
- VB如何实现摄像头数据的捕获与显示
- Flex 捕获摄像头拍照
- Flex 捕获摄像头拍照
- 使用摄像头捕获图片
- windows 捕获摄像头1
- OpenCV摄像头捕获
- C#如何捕获windows关机事件
- C#调用C++库,如何捕获异常
- C# 如何采集摄像头的视频
- 开发人员用的提交测试环境的AutoIT脚本
- C++ LIST实例
- 注册表reg文件语法规则
- Windows Media Encode 9简介及SDK
- 人啊,
- c#如何捕获摄像头内容?
- Discuz7.0程序二次开发必备:目录详解
- 'POPUP_TO_DECIDE_LIST'函数测试
- JS读取本地文件及目录的方法
- js插件
- 一个简单的 Qt GUI 程序
- zoj 3121 Arne Saknussemm
- 创建非模态对话框
- 使用AES算法加密字符串