当前上下文中不存在名称捕获错误
您好,我正在开发一个露营捕获应用程序。我目前正在使用 EmguCV 2.0。我收到以下代码行的错误:
Image
我已经添加了 EmguCV 的所有必需引用,例如 Emgu.CV、Emgu.CV.UI、Emgu.CV.ML、Emgu.Util,但仍然给出错误:
Error 1 The name 'capture' 在当前上下文中不存在 C:\Documents and Settings\TLNA\my Documents\visual studio 2010\Projects\webcamcapture\webcamcapture\Form1.cs 27 38 webcamcapture
我从 此处。完整的程序代码如下:-
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.UI;
using Emgu.CV.Structure;
using Emgu.CV.ML;
namespace webcamcapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
Image<Bgr, Byte> image = capture.QueryFrame();
pictureBox1.Image = image.ToBitmap(pictureBox1.Width, pictureBox1.Height);
}
}
}
Hi I am developing a campera capture application. I am currently using EmguCV 2.0. I get an error with the following line of code :
Image<Bgr, Byte> image = capture.QueryFrame();
I have added all the required references of EmguCV like Emgu.CV,Emgu.CV.UI, Emgu.CV.ML, Emgu.Util, but still it gives a error saying :
Error 1 The name 'capture' does not exist in the current context C:\Documents and Settings\TLNA\my documents\visual studio 2010\Projects\webcamcapture\webcamcapture\Form1.cs 27 38 webcamcapture
I got this code from here. The full program code is given below:-
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.UI;
using Emgu.CV.Structure;
using Emgu.CV.ML;
namespace webcamcapture
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
Image<Bgr, Byte> image = capture.QueryFrame();
pictureBox1.Image = image.ToBitmap(pictureBox1.Width, pictureBox1.Height);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您忘记声明一个用于捕获的变量。
编辑:我自己从来没有使用过 emgu,我帮不了什么忙,但是在谷歌上花了几分钟,我偶然发现了 http://www.emgu.com/wiki/index.php/Tutorial#Examples 这可能会帮助您正确设置捕获对象。
Looks like you forgot to declare a variable for capture.
Edit: never having used emgu myself, i cant help much, but a couple mins on google and i stumbled across http://www.emgu.com/wiki/index.php/Tutorial#Examples which might help you set up the capture object properly.