Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi I want to create a form with a button and a picturebox, then link it with opencv library.can someone help me and
how can do it in vc++ windows forms application, i dont need to use MFC or win32
thanks
Posted
Comments
Sergey Alexandrovich Kryukov 25-Mar-12 21:36pm    
Of course, with C++/CLI, MCF is not an option, but -- what is the problem? Just use it. You can develop different kinds of .NET applications, including Forms.
(And don't abuse PictureBox, use it only for simple static images, don't try to do anything dynamic, interactive, animated, etc., for such purposes use custom control.)
--SA
thaer.sqor 25-Mar-12 22:36pm    
Hi
My problem is to link the library with the VC++ windows Forms Application, I do not know how.
I hope help, and I hope that there is an example of

Thanks
thaer.sqor 25-Mar-12 22:43pm    
Well, but I do not know programming through "Win32"
I hope you give me a book for that.
thanks

1 solution

You can create a class that uses openCV classes and functions and then declare a global instance of that class and you can reference it in managed .NET code.
You can't instantiate an unmanaged class in the form class.
 
Share this answer
 
Comments
thaer.sqor 2-Apr-12 13:06pm    
okay, but ... how i can do that
BupeChombaDerrick 2-Apr-12 14:42pm    
For example, you want to run a Haar Face detector but with a .NET C++/CLI GUI , create a class called FaceDetector in a File FaceDetector.h and implementation file FaceDetector.cpp.

class FaceDetector
{
public: FaceDetector();

public: ~FaceDetector();

public: void readFromBitmap(Bitmap ^bmp); //convert to cv::Mat frame

public: void copyToBitmap(Bitmap ^bmp); //copy from cv::Mat frame to bitmap

public: void detectAndDraw();

// TO-DO: write methods that use openCV haar classifier for Face detection
// get data from a .NET Bitmap using readFromBitmap() and run face
// detection using detectAndDraw() then copy results to Bitmap using
// copyToBitmap() and you can then show the results on a Picture Box
public: Mat frame;
};

then you can include a header FaceDetector.h in your .NET C++/CLI project

then just before the form class code declare a FaceDetector object.

#include "FaceDetector.h"

FaceDetector faceDetector; //global declaration

// C++/CLI code here

then whithin the Form class you can easily call reference the faceDetector object.

or you can use Emgu CV .NET wrapper for openCV see http://sourceforge.net/projects/emgucv/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900