EmguCV 打开相机但不查看 ImageBox 中的帧
EmguCV opens the camera but doesn't view frames in ImageBox
我正在尝试在 windows x64Bit 上使用 c#
制作一个简单的 openCV
相机应用程序。
为此,我将 cvextern.dll
、Emgu.CV.dll
、Emgu.CV.UI.dll
、Emgu.Util.dll
和所有 opencv_*.dll
文件复制到解决方案的调试文件夹中。
我添加文件 Emgu.CV.dll
、Emgu.CV.UI.dll
和 Emgu.Util.dll
作为参考。
在表单 CameraCapture
中,当我单击按钮 btnStart
时,相机帧应该显示在图像框中 CamImageBox
。
这是我的代码
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.Util;
namespace CameraCapture
{
public partial class CameraCapture : Form
{
private Capture capture;
private bool captureInProgress;
public CameraCapture()
{
InitializeComponent();
}
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
CamImageBox.Image = ImageFrame;
}
private void btnStart_Click(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (capture == null)
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if (capture != null)
{
if (captureInProgress)
{
btnStart.Text = "Start!"; //
Application.Idle -= ProcessFrame;
}
else
{
btnStart.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
}
private void ReleaseData()
{
if (capture != null)
capture.Dispose();
}
}
}
此代码在构建项目时未显示任何错误。问题是,当我 运行 项目并按下按钮 btnStart
时,图像框中没有任何显示 CamImageBox
。
代码没有显示错误。相机工作正常。当我 运行 项目时,我的相机灯亮起 "camera starts working when I run the project" 但我没有收到图像框中的任何图片。
文件、项目配置中是否缺少某些内容?
在您的 'using' 中添加 'Using.Emgu.CV.UI'..试试吧
我正在尝试在 windows x64Bit 上使用 c#
制作一个简单的 openCV
相机应用程序。
为此,我将 cvextern.dll
、Emgu.CV.dll
、Emgu.CV.UI.dll
、Emgu.Util.dll
和所有 opencv_*.dll
文件复制到解决方案的调试文件夹中。
我添加文件 Emgu.CV.dll
、Emgu.CV.UI.dll
和 Emgu.Util.dll
作为参考。
在表单 CameraCapture
中,当我单击按钮 btnStart
时,相机帧应该显示在图像框中 CamImageBox
。
这是我的代码
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.Util;
namespace CameraCapture
{
public partial class CameraCapture : Form
{
private Capture capture;
private bool captureInProgress;
public CameraCapture()
{
InitializeComponent();
}
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
CamImageBox.Image = ImageFrame;
}
private void btnStart_Click(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (capture == null)
{
try
{
capture = new Capture();
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if (capture != null)
{
if (captureInProgress)
{
btnStart.Text = "Start!"; //
Application.Idle -= ProcessFrame;
}
else
{
btnStart.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
}
private void ReleaseData()
{
if (capture != null)
capture.Dispose();
}
}
}
此代码在构建项目时未显示任何错误。问题是,当我 运行 项目并按下按钮 btnStart
时,图像框中没有任何显示 CamImageBox
。
代码没有显示错误。相机工作正常。当我 运行 项目时,我的相机灯亮起 "camera starts working when I run the project" 但我没有收到图像框中的任何图片。
文件、项目配置中是否缺少某些内容?
在您的 'using' 中添加 'Using.Emgu.CV.UI'..试试吧