Instalacija

OpenCV je skup biblioteka za obradu slika na racunalu. Ovdje se nalaze upute kao ga instalirati.

Linux

Ubuntu (Debian):

sudo apt-get install g++ libopencv-dev

Windows

Potrebno preuzeti i instalirati

MinGW

http://sourceforge.net/projects/mingw/files/latest/download

Instalirajte ga u D:\frameworks\MinGW. Nemojte zaboraviti instalirati i C++ compiler!

Preporucio bih da dodate bin direktorij u PATH enivronment varijablu.

Code::Blocks

http://sourceforge.net/projects/codeblocks/files/Binaries/12.11/Windows/codeblocks-12.11-setup.exe/download

Prilikom prvog otvaranja pitat ce vas za kompilator. Tu zelite odabrati MinGW, koji ste instalirali u proslom koraku. Kasnije to mozete napraviti ovako: Settings > Compiler... > Global Compiler Settings > GNU GCC Compiler > Toolchain executables > Compiler's installation directory postavite na D:\frameworks\MinGW.

Usput mozete ukljuciti i slijedece opcije (Compiler settings):

CMake

http://www.cmake.org/files/v2.8/cmake-2.8.10.2-win32-x86.exe

OpenCV

http://sourceforge.net/projects/opencvlibrary/files/latest/download?source=files

Otpakirajte ga u D:/frameworks/src/opencv.

Konfiguracija instalacije

Ukratko:

  1. Otvorite CMake GUI:
    1. Where is the source code: D:/frameworks/src/opencv
    2. Where to build the binaries: D:/frameworks/opencv
  2. Pritisnite Configure - ne smije se pojaviti crveni tekst dolje. Ako se pojavi, pingajte @brahle
  3. Ako imate visejezgreni procesor, ukljucite opcije WITH_TBB i WITH_IPP.
  4. Pritisnite Generate

Pogledajte http://opencv.willowgarage.com/wiki/InstallGuide#Build za nesto detaljniji opis.

Kompiliranje OpenCV

  1. Otvorite CMD (Start > Run > cmd)
  2. Otidjite u direktorij D:/frameworks/opencv
  3. Upisite mingw32-make -j (-j ide bez numerickog parametra)
  4. Pricekajte dosta dugo - cca 20ak minuta

Konfiguriranje Code::Blocksa

  1. Otvorite Settings > Compiler... > Global Compiler Settings > GNU GCC Compiler > Linker settings
    1. Pritisnite Add
    2. Odaberite sve .dll datoteke iz D:/frameworks/opencv/bin
  2. Otvorite tab Search directories
    1. Pritisnite Add
    2. Dodajte D:/frameworks/src/opencv/build/include
  3. OK

Testiranje radi li sve

  1. Napravite novi Empty projekt u Code Blocksu.
  2. Otvorite main.cpp ga i zalijepite ovaj kod: P68
  3. Kopirjate D:\frameworks\src\opencv\samples\cpp\baboon.jpg u svoj projekt.
  4. Pritisnite F9
  5. Nadajte se da vidite majmuna

Troubleshooting

CMake

CMake Error at D:/Program Files (x86)/CMake 2.8/share/cmake 2.8/Modules/CMakeMinGWFindMake.cmake:20 (message):
sh.exe was found in your PATH, here:

D:/Program Files (x86)/Git/bin/sh.exe

For MinGW make to work correctly sh.exe must NOT be in your path.

Run cmake from a shell that does not have sh.exe in your PATH.

If you want to use a UNIX shell, then use MSYS Makefiles.

Ova pogreska se rijesi tako da se izbaci D:/Program Files (x86)/Git/bin iz patha. Na Windowsima 8:

  1. Start
  2. Utpikatje Advanced System
  3. Odaberite Settings
  4. Environment Variables...
  5. Iz PATH-a izbrisete gore navedeni put (D:/Program Files (x86)/Git/bin)
  6. Izadjite i izadjite iz CMakea.
© 2013. Bruno Rahle Creative Commons License

Ovaj Ĩlanak objavljen je pod
Creative Commons Attribution-ShareAlike 3.0 Croatia License