当我使用版本1.0.2395.24959的webcam_capture.dll时,停止功能不起作用 [英] Stop function is not working when i am using webcam_capture.dll of version 1.0.2395.24959
问题描述
捕获图像我想要''使用网络摄像头。为此,我使用webcam_capture.dll,但这不能正常工作。停止功能无法正常工作。请告诉我如何在初始化网络摄像头后停止网络摄像头..我正在使用此代码。
使用系统;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing ;
使用System.Text;
使用System.Windows.Forms;
使用System.IO;
使用WinFormCharpWebCam;
命名空间Camera_Sample
{
公共部分类Form1:表格
{
WebCam网络摄像头; //为处理从Webcamera捕获图像的任务而创建的自定义类
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender,EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgCam);
}
private void btnStart_Click(object sender,EventArgs e)
{
webcam.Start();
}
private void btnStop_Click(object sender,EventArgs e)
{
webcam。停止();
}
private void imgPreview_Click(object sender,EventArgs e)
{
}
private void btnCont inue_Click(对象发送者,EventArgs e)
{
webcam.Continue();
}
private void btnClick_Click(object sender,EventArgs e)
{
imgPreview.Image = imgCam.Image;
}
private void btnSave_Click(object sender,EventArgs e)
{
SaveFileDialog sdialog = new SaveFileDialog() ;
sdialog.FileName =Image; //默认文件名
sdialog.DefaultExt =Jpg; //默认文件扩展名
sdialog.Filter =Image(.jpg)| * .jpg; //按扩展名过滤文件
//显示保存文件对话框
//处理保存文件对话框结果
if(sdialog.ShowDialog()== DialogResult.OK)
{
//保存图片
string filename = sdialog。 FileName;
FileStream fstream = new FileStream(filename,FileMode.Create);
imgPreview.Image.Save(fstream,System.Drawing.Imaging.ImageFormat.Jpeg);
fstream.Close();
}
}
}
}
WebCam。 cs摄像头课程
使用系统;
使用System.IO;
使用System.Text;
使用WebCam_Capture;
使用System.Collections.Generic;
< br $>
namesp ace CSharpWebCam
{
//由Dharma Iyer设计
class WebCam
{
private WebCamCapture网络摄像头;
私有System.Windows.Forms.PictureBox _FrameImage;
private int FrameNumber = 30;
public void InitializeWebCam( ref System.Windows.Forms.PictureBox ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber =((ulong) (0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured + = new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}
void webcam_ImageCaptured(对象源,WebcamEventArgs e)
{
_FrameImage.Image = e.WebCamImage;
}
public void开始()
{
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.Start(0);
}
public void Stop()
{
webcam.Stop();
}
public void继续()
{
//更改捕获时间框架
webcam.TimeToCapture_milliseconds = FrameNumber;
//从停止恢复视频捕获
webcam.Start(这个.webcam.FrameNumber);
}
public void ResolutionSetting()
{
webcam.Config();
}
public void AdvanceSetting()
{
webcam.Config2();
}
内部无效InitializeWebCam(System.Windows.Forms.PictureBox imgCam)
{
抛出新的NotImplementedException();
}
}
}
for capture image i want''a use webcam. for this i use webcam_capture.dll but this is not working properly.stop function is not working. so tell me please how to stop the webcam after Initializing the webcam.. im using this code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using WinFormCharpWebCam;
namespace Camera_Sample
{
public partial class Form1 : Form
{
WebCam webcam; //customized class created for handling the task of capturing image from Webcamera
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgCam);
}
private void btnStart_Click(object sender, EventArgs e)
{
webcam.Start();
}
private void btnStop_Click(object sender, EventArgs e)
{
webcam.Stop();
}
private void imgPreview_Click(object sender, EventArgs e)
{
}
private void btnContinue_Click(object sender, EventArgs e)
{
webcam.Continue();
}
private void btnClick_Click(object sender, EventArgs e)
{
imgPreview.Image = imgCam.Image;
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog sdialog = new SaveFileDialog();
sdialog.FileName = "Image";// Default file name
sdialog.DefaultExt = ".Jpg";// Default file extension
sdialog.Filter = "Image (.jpg)|*.jpg"; // Filter files by extension
// Show save file dialog box
// Process save file dialog box results
if (sdialog.ShowDialog() == DialogResult.OK)
{
// Save Image
string filename = sdialog.FileName;
FileStream fstream = new FileStream(filename, FileMode.Create);
imgPreview.Image.Save(fstream, System.Drawing.Imaging.ImageFormat.Jpeg);
fstream.Close();
}
}
}
}
WebCam.cs Class for webcam
using System;
using System.IO;
using System.Text;
using WebCam_Capture;
using System.Collections.Generic;
namespace CSharpWebCam
{
//Design by Dharma Iyer
class WebCam
{
private WebCamCapture webcam;
private System.Windows.Forms.PictureBox _FrameImage;
private int FrameNumber = 30;
public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber = ((ulong)(0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}
void webcam_ImageCaptured(object source, WebcamEventArgs e)
{
_FrameImage.Image = e.WebCamImage;
}
public void Start()
{
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.Start(0);
}
public void Stop()
{
webcam.Stop();
}
public void Continue()
{
// change the capture time frame
webcam.TimeToCapture_milliseconds = FrameNumber;
// resume the video capture from the stop
webcam.Start(this.webcam.FrameNumber);
}
public void ResolutionSetting()
{
webcam.Config();
}
public void AdvanceSetting()
{
webcam.Config2();
}
internal void InitializeWebCam(System.Windows.Forms.PictureBox imgCam)
{
throw new NotImplementedException();
}
}
}
推荐答案
你查过这篇文章了吗?
多功能WebCam C#库 [ ^ ]
祝你好运!
Have you checked this article?
Versatile WebCam C# library[^]
Good luck!
这篇关于当我使用版本1.0.2395.24959的webcam_capture.dll时,停止功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!