C# emgu cv中的摄像头,没有出现错误,但当我按下开始按钮时,摄像头开始工作,但没有拍摄图像
我在emgu cv中为相机编写了代码,没有出现错误,但当我按下开始按钮时,相机开始工作,但没有拍摄图像。正在拍摄其他项目图像。非常感谢您的帮助C# emgu cv中的摄像头,没有出现错误,但当我按下开始按钮时,摄像头开始工作,但没有拍摄图像,c#,emgucv,C#,Emgucv,我在emgu cv中为相机编写了代码,没有出现错误,但当我按下开始按钮时,相机开始工作,但没有拍摄图像。正在拍摄其他项目图像。非常感谢您的帮助 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.F
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.Util;
namespace camstop
{
public partial class cameracapture : Form
{
private Capture capture;
private bool captureinprogress;
public cameracapture()
{
InitializeComponent();
}
private void processFrame(object sender, EventArgs e)
{
Image<Bgr, Byte> imageframe = capture.QueryFrame();
cameraimagebox.Image = imageframe;
pictureBox1.Image = imageframe.ToBitmap();
imageframe.Save(@"E:\\photo\\Mypic.jpg");
}
private void btnstart_Click(object sender, EventArgs e)
{
if (capture == null)
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
if (capture != null)
{
if (captureinprogress)
{ //if camera is getting frames then stop the capture and set button Text
// "Start" for resuming capture
btnstart.Text = "Start!"; //
Application.Idle -= processFrame;
}
}
else
{
//if camera is NOT getting frames then start the capture and set button
// Text to "Stop" for pausing capture
btnstart.Text = "Stop!";
Application.Idle += processFrame;
}
captureinprogress = !captureinprogress;
}
private void ReleaseData()
{
if (capture != null)
capture.Dispose();
}
private void cameracapture_Load(object sender, EventArgs e)
{
}
}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Windows.Forms;
使用Emgu.CV;
使用Emgu.CV.Structure;
使用Emgu.CV.Util;
名称空间camstop
{
公共部分类摄影机捕捉:表单
{
私人捕获;
私人bool captureinprogress;
公共摄像
{
初始化组件();
}
私有void processFrame(对象发送方、事件参数)
{
Image imageframe=capture.QueryFrame();
cameraimagebox.Image=imageframe;
pictureBox1.Image=imageframe.ToBitmap();
imageframe.Save(@“E:\\photo\\Mypic.jpg”);
}
私有void btnstart_单击(对象发送方,事件参数e)
{
如果(捕获==null)
{
尝试
{
捕获=新捕获();
}
捕获(NullReferenceExcpt)
{
MessageBox.Show(除消息外);
}
}
如果(捕获!=null)
{
if(captureinprogress)
{//如果相机正在获取帧,则停止捕获并设置按钮文本
//用于恢复捕获的“启动”
btnstart.Text=“开始!”//
Application.Idle-=processFrame;
}
}
其他的
{
//如果相机未获取帧,则启动“捕获并设置”按钮
//用于暂停捕获的“停止”文本
btnstart.Text=“停止!”;
Application.Idle+=processFrame;
}
captureinprogress=!captureinprogress;
}
私有void ReleaseData()
{
如果(捕获!=null)
capture.Dispose();
}
私有void cameracapture_加载(对象发送方,事件参数e)
{
}
}
}转到click事件并调用btnstart方法,用于imagebox和button。。 如果未找到“form”中的问题,请更改名称空间名称并在program.cs中调用form1名称