Windows ms visual c ++ install opencv
Download
Opencv installer and install it. I assume you have installed onto C:/program files/opencv.
Setup ms visual c ++
I write details based on MS Visual Studio 2005. Follow menus of MS VISUAL C ++ window:
- Tools> Options> projects and solutions> VC ++ directories>
- Show directory for:> include files. Now add
C:/Program Files/OpenCV/cv/includeC:/Program Files/OpenCV/cvaux/includeC:/Program Files/OpenCV/cxcore/includeC:/Program Files/OpenCV/otherlibs/highguiC:/Program Files/OpenCV/ml/includeC:/Program Files/OpenCV/otherlibs/cvcam/include
- Show directory for:> library files. Now add
C:/Program Files/OpenCV/lib
- (Option) show directory for:> source files. Now add
C:/Program Files/OpenCV/cv/srcC:/Program Files/OpenCV/cvaux/srcC:/Program Files/OpenCV/cxcore/srcC:/Program Files/OpenCV/otherlibs/highguiC:/Program Files/OpenCV/otherlibs/cvcam/src/windows
Setup ms visual c ++ for each project
- Right click Project> property>
- Configuration proeperties> linker> input> additional dependencies. Now add
- Cv. Lib cxcore. Lib cvaux. Lib highgui. Lib ml. Lib cvcam. Lib
- Change 'configuration' drop down menu from release (Debug) to debug (release ).
- Do the same thing (Add. libs to input)
Or, add below codes into your source codes abve # include (s ).
#ifdef _MSC_VER#pragma comment(lib, "cv.lib")#pragma comment(lib, "cxcore.lib")#pragma comment(lib, "cvaux.lib")#pragma comment(lib, "highgui.lib")#pragma comment(lib, "ml.lib")#pragma comment(lib, "cvcam.lib")#endif
Mingw gcc/g ++ install mingw
Mingwis a collection of freely available and freely distributable windowsspecific header files and import libraries, augmenting the GNU compilercollection, (GCC), and its associated tools, (GNU binutils). mingwprovides a complete open source
Programming tool set which is suitablefor the development of Native Windows programs that do not depend onany 3rd-party C Runtime DLLs.
- Download automated mingw installer from
Mingw project page and install.
- Install GCC and G77
- Assume mingw is installed on C:/mingw
- Mingw originally does not include gdb debugger. If you want it, download .tar.bz2 of GNU source-level debugger from
Mingw project page and unarchive it.
- Copy files into C:/mingw
How to compile
g++ test.cpp -I"C:/Program Files/OpenCV/cv/include" -I"C:/Program Files/OpenCV/cxcore/include" -I"C:/Program Files/OpenCV/otherlibs/highgui" -L"C:/Program Files/OpenCV/lib" -lcxcore -lcv -lhighgui -lcvaux -lml
How to Use mingw on cygwin
Cygwinis a Linux-like environment for Windows. it consists of two parts: adll (cygwin1.dll) which acts as a Linux API emulation layer providingsubstantial Linux API functionality. a collection of tools whichprovide Linux look and feel.
Http://www.cygwin.com/
Setup to use mingw g ++ instead of cygwin g ++
$ export PATH=/cygdrive/c/MinGW/bin:$PATH
Linux gcc/g ++
Download
Opencv source codes (.tar.gz)
Root User
tar zxvf opencv-1.0.0.tar.gz; cd opencv-1.0.0./configuremakemake install
General User
tar zxvf opencv-1.0.0.tar.gz; cd opencv-1.0.0./configure --prefix=$HOME/usrmakemake install# configurationexport PATH=$HOME/usr/bin/:$PATHexport LD_LIBRARY_PATH=$HOME/usr/lib:$LD_LIBRARY_PATHexport PKG_CONFIG_PATH=$HOME/usr/lib/pkgconfig:$PKG_CONFIG_PATHexport MANPATH=$HOME/usr/man:$MANPATH
Compilation is
g++ `pkg-config --cflags opencv` foo.c -o foo `pkg-config --libs opencv`
It must be equivalent
g++ -I$HOME/usr/include/opencv foo.c -o foo -L$HOME/usr/lib -lcxcore -lcv -lhighgui -lcvaux -lml
Where $ home/usr is the prefix specified at the./configure step.
MacOS X
I tried long time ago, there shoshould exist easier ways nowadays.
Sample Test code
#include #include #include #include #include int main(int argc, char *argv[]){ // Nothing but create a window cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); cvMoveWindow("mainWin", 100, 100); cvWaitKey(0); return 0;}