Abozanona
Abozanona

Reputation: 2295

EmguCV opens the camera but doesn't view frames in ImageBox

I'm trying to make a simple openCV camera application with c# on windows x64Bit.

To do so, I copied cvextern.dll, Emgu.CV.dll, Emgu.CV.UI.dll, Emgu.Util.dll and all opencv_*.dll files to the solution's debug folder.
I add the files Emgu.CV.dll, Emgu.CV.UI.dll and Emgu.Util.dll as refrence.

In the form CameraCapture when I click the button btnStart the camera frames shoud be displayed in the Imagebox CamImageBox.

here's my code

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

This code doesn't show any error while building the project. The problem is that when I run the project and press the button btnStart nothing is displayed in the Imagebox CamImageBox.

The code shows me no errors. The camera is working fine. When I run the project My camera's light turn on "camera starts working when I run the project" But I don't recieve any picture in the Imagebox.

Is there something I'm missing with the files, project configration?

Upvotes: 2

Views: 1556

Answers (1)

zen
zen

Reputation: 36

to your 'using' add 'Using.Emgu.CV.UI'..just try that

Upvotes: 2

Related Questions