【问题标题】:Capturing an image with Emgu - black image使用 Emgu 捕获图像 - 黑色图像
【发布时间】:2019-01-23 16:03:57
【问题描述】:

我是 emgu cv 的新手,对于一个大型项目,我正在尝试从网络摄像头捕获图像并将其显示在图像框中,但它显示的是黑色图像。

以下代码有什么问题?

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.UI;
using Emgu.Util;

namespace WindowsFormsApplication7
{
    public partial class Form1 : Form
    {
        private Capture capture;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (capture == null)
               capture = new Capture();
            Image<Bgr,Byte> img=capture.QueryFrame();
            imageBox1.Image = img;                 
        }
    }
}

【问题讨论】:

  • 你应该提供更多关于你的网络摄像头的信息,如果它是内置的笔记本电脑,以及你使用的是哪个 emgu 版本。 Howewer 尝试运行使用网络摄像头的 Opencv 示例,如果它不起作用,这不是 emgu 问题,而是 opencv 问题。
  • 您是否尝试过运行 Emgu 附带的示例应用程序之一?例如 VideoSurveillance 示例。

标签: c# emgucv


【解决方案1】:

我认为有一个小错误。

改用这个:

声明为全局变量:

Capture capture = default(Capture);

加载这个:

capture = new Capture(0);
Control.CheckForIllegalCrossThreadCalls = false;
System.Threading.Thread t = new System.Threading.Thread(grab);

t.Start();

创建一个子抓取并放入,

do {
    ImageBox1.Image = capture.QueryFrame();
} while (true);

干杯
什雷亚斯

【讨论】:

    【解决方案2】:

    拨打QueryFrame() 两次,对我有用:

     if (capture == null)
               capture = new Capture();
     capture.QueryFrame();
     Image<Bgr,Byte> img=capture.QueryFrame().ToImage<Bgr, Byte>();
     imageBox1.Image = img.Bitmap;
    

    【讨论】:

      【解决方案3】:

      就我而言,卡巴斯基杀毒软件阻止了对我的网络摄像头的访问。在更改了一些安全设置后,我能够让 emgu capture 恢复工作。

      【讨论】:

        猜你喜欢
        • 2012-01-07
        • 2020-12-22
        • 2017-12-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-17
        • 1970-01-01
        • 2011-01-21
        相关资源
        最近更新 更多