我正在使用c#项目。所以在这里我使用了emguCV图像处理库。这是我访问网络摄像头并停止的示例代码。这段代码有效,但当我停止视频设备时,它无法正常停止。
private void btnStart_Click(object sender, EventArgs e)
{
if(capture==null){
try
{
capture = new Capture();
}
catch(NullReferenceException ex){
MessageBox.Show(ex.Message);
}
}
if(capture!=null){
if (captureInProgress)
{
btnStart.Text = "!Start";
Application.Idle -= ProcessFrame;
}
else {
btnStart.Text = "Stop";
Application.Idle += ProcessFrame;
}
}
captureInProgress = !captureInProgress;
}
我在这里错过了什么。请帮帮我。
答案 0 :(得分:0)
private void btnStart_Click(object sender, EventArgs e)
{
if(capture==null){
try
{
capture = new Capture();
}
catch(NullReferenceException ex){
MessageBox.Show(ex.Message);
}
}
if(capture!=null){
if (captureInProgress)
{
btnStart.Text = "!Start";
capture.Stop(); //you miss this
Application.Idle -= ProcessFrame;
}
else {
btnStart.Text = "Stop";
capture.Start(); //you miss this
Application.Idle += ProcessFrame;
}
}
captureInProgress = !captureInProgress;
}