gpt4 book ai didi

c# - EmguCV 打开相机但不查看 ImageBox 中的帧

转载 作者:太空宇宙 更新时间:2023-11-03 21:35:29 25 4
gpt4 key购买 nike

我正在尝试在 Windows x64Bit 上使用 c# 制作一个简单的 openCV 相机应用程序。

为此,我复制了 cvextern.dllEmgu.CV.dllEmgu.CV.UI.dllEmgu.Util.dll 和所有 opencv_*.dll 文件到解决方案的调试文件夹。
我添加文件 Emgu.CV.dllEmgu.CV.UI.dllEmgu.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 时,Imagebox CamImageBox 中没有显示任何内容。

代码没有显示错误。相机工作正常。当我运行项目时,我的相机灯亮起“当我运行项目时相机开始工作”但是我没有在 Imagebox 中收到任何图片。

文件、项目配置中是否缺少某些内容?

最佳答案

在你的'using'中添加'Using.Emgu.CV.UI'..试试吧

关于c# - EmguCV 打开相机但不查看 ImageBox 中的帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31731648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com