Beginning Emgu CV with C++

Ask questions on using Emgu CV with C++
Post Reply
otakrosak
Posts: 3
Joined: Sun Jul 19, 2009 9:44 am

Beginning Emgu CV with C++

Post by otakrosak » Sun Jul 19, 2009 10:01 am

Hello everyone.

I am a new user to Emgu CV and I am interested in programming with it in C++. There doesn't seem to be a lot of examples in C++ and I find it rather frustrating.

What I would like to know is where do we declare the "using Emgu.CV" namespace? In OpenCV everything was done in the main C++ file, but since I am now creating a Windows Form Application, the rules of the game seems to have changed slightly. Also, when I declare the namespace in the Form1.h file, the following errors appear:

Code: Select all

//the namespace declaration
using Emgu.CV;
using Emgu.CV.Structure;

Code: Select all

EmguCV_Test.cpp
\Form1.h(12) : error C2143: syntax error : missing ';' before '.'
\Form1.h(12) : error C2873: 'Emgu' : symbol cannot be used in a using-declaration
\Form1.h(12) : error C2059: syntax error : '.'
\Form1.h(13) : error C2143: syntax error : missing ';' before '.'
\Form1.h(13) : error C2873: 'Emgu' : symbol cannot be used in a using-declaration
\Form1.h(13) : error C2059: syntax error : '.'
I have followed all the steps on the EmguCV wiki, and I have searched Google, but as I mentioned earlier, there seems to be a lack of C++ examples. Am I doing something wrong? Is it actually easier than I'm making it out to be? Any help would be very much appreciated.

Sincerely,
otakrosak

canming
Site Admin
Posts: 1038
Joined: Thu Feb 28, 2008 4:16 pm

Re: Beginning Emgu CV with C++

Post by canming » Sun Jul 19, 2009 4:17 pm

Use

Code: Select all

using Emgu::CV;
using Emgu::CV::Structure
Btw, open Emgu.CV.Exmple solution under Solution\VS2005_Monodevelop\Emgu.CV.Example.sln, there is a C++ example project.

otakrosak
Posts: 3
Joined: Sun Jul 19, 2009 9:44 am

Re: Beginning Emgu CV with C++

Post by otakrosak » Mon Jul 20, 2009 11:18 am

Thanks so much for the info, canming. Truly helped me out a lot!

otakrosak
Posts: 3
Joined: Sun Jul 19, 2009 9:44 am

Re: Beginning Emgu CV with C++

Post by otakrosak » Tue Jul 21, 2009 1:16 am

Hello again.

I have another question. The C++ example given in the solution is for a predefined image. How do you go about creating a C++ application that has a button to load any image, and another button to perform actions onto that image (i.e., filtering, histogram, etc). Also, what is the equivalent to cvLoadImage in EmguCV? I have a button that calls up an Open File Dialog box and I copied the path to a string and I want to assign that to IplImage so that I can copy it the managed EmguCV wrapper.

Code: Select all

//What I propose to do on a Windows Form Application

OpenFileDialog^ dlg = gcnew OpenFileDialog();

if(dlg->ShowDialog() == Windows::Forms::DialogResult::OK){
    String^ path = dlg->FileName;
    Image<Bgr^, byte^>^ image = gcnew Image<Bgr^, byte>(path);
}
Any help would be truly appreciated.

Sincerely,
otakrosak

Post Reply