Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I usually start with a windows form application and add the openCV code in the callback functions. The form header just has the declarations for the form callbacks with the code in the associated cpp file. This is not the default for visual c++ but is the "proper" way to do things in C.

Within the header I do not include any OpenCV elements. I put the

    #include "opencv2\opencv.hpp"
    #include "opencv2\highgui\highgui.hpp"
    #include "opencv2\imgproc\imgproc.hpp"
...
    using namespace cv;

at the top of the .cpp file. all Mat's are declared internally in the callback or as global variables at the .cpp level. in the project properties make sure to:

  • Add $(OPENCV_DIR)....\include to C/C++ -> General -> Additional Include Directories
  • Add $(OPENCV_DIR)\lib to Linker->General->Additional Library Directories
  • Add opencv_core249d.lib and any other libraries you are using to Linker->Input->Additional Dependancies (replace 249 with the version you are using, the d denotes to use the debug version of the libraries and can be ommitted.)

This works well for me.

guy