1

私は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;                 
        }
    }
}
4

3 に答える 3

0

2回電話QueryFrame()してください、それは私にとってはうまくいきます:

 if (capture == null)
           capture = new Capture();
 capture.QueryFrame();
 Image<Bgr,Byte> img=capture.QueryFrame().ToImage<Bgr, Byte>();
 imageBox1.Image = img.Bitmap;
于 2016-09-28T10:27:24.627 に答える
0

小さな間違いがあると思います。

代わりにこれを使用してください:

グローバル変数として宣言:

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);

乾杯
シュレヤス

于 2012-03-24T18:09:41.683 に答える