Opencv learning-Installation Summary of various environments (Summary)

Source: Internet
Author: User
Tags gdb debugger
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.

  • Install xcode from OS CD, 'custom' to install everything.
  • Get opencv and
    Http://lestang.org/article45.html.
  • Copy these files into opencv.
  • ./Configure to create cvconfig. h.
  • Double click xcode project in _ make, add path of the cvconfig. h to highgui.
  • Build, try projects of samples.
  • Toexecute builded program on command line, copy_make/build/debug/*. Framework ~ /Library/frameworks. If frameworksdoes not exist, create it.
    $ _make/build/Debug/kmeans.app/Contents/MacOS/kmeans
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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.