-1
ここでは、emgucv-windows-x86 2.2.1.1150
を使用したノートパソコンのウェブカメラから画像ボックスにライブ画像ストリームを表示しようとしています。 (注:私はWindows 64bitを使用しています)。Emgucvに画像を表示するには
最初にテキストがStart!
のボタンを使用しました。私たちが望むのは、Start!
ボタンを押すとカメラが作動し、画像ストリームがImageBox
に表示されるはずです。ストリームがオンの場合は、開始ボタンにPause
が表示され、ストリームを一時停止する必要があります。
ウェブカメラが動作しているにも関わらず、ライブストリームイメージを表示する代わりに、エラーが全くない場合でもStart!
ボタンを押してもImageBoxに何も表示されないという問題があります。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.Util;
namespace CameraCapture
{
public partial class cameracapture : Form
{
//declaring global variables
private Capture capture; //takes images from camera as image frames
private bool captureInProgress; // checks if capture is executing
public cameracapture()
{
InitializeComponent();
}
//------------------------------------------------------------------------------//
//Process Frame() below is our user defined function in which we will create an EmguCv
//type image called ImageFrame. capture a frame from camera and allocate it to our
//ImageFrame. then show this image in ourEmguCV imageBox
//------------------------------------------------------------------------------//
private void ProcessFrame(object sender, EventArgs arg)
{
Image<Bgr, Byte> ImageFrame = capture.QueryFrame();
CamImageBox.Image = ImageFrame;
}
private void cameracapture_Load(object sender, EventArgs e)
{
}
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)
{ //if camera is getting frames then stop the capture and set button Text
// "Start" for resuming capture
btnStart.Text = "Start!"; //
Application.Idle -= ProcessFrame;
}
else
{
//if camera is NOT getting frames then start the capture and set button
// Text to "Stop" for pausing capture
btnStart.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
}
private void ReleaseData()
{
if (capture != null)
capture.Dispose();
}
}
}
私が間違っている場合は私を修正しますが、私はこのコードを他の場所で見ました。あなたはあなたの出身を述べるべきです。 – Syphirint