Thursday, February 2, 2012

Setting up opencv on DEV C++



This is really simple if you know what to do .

  1. Download OpenCV : install ; check the path where it is installed. for eg C:\Opencv2.x
  2. Download DevCPP: install ;

Once done with both
Open Dev Cpp.Go to TOOLS - COMPILER OPTIONS . ADD new compiler (click on plus sign).
Name it OpenCV.

Add these lines and tick
Add these foll commands while calling compiler
-L"C:\OpenCV\lib" -lcxcore210 -lcv210 -lcvaux210 -lhighgui210 -lml210

while doing so change the lib path( C:\OpenCV\lib) according to the path you have saved.GO to the lib folder in opencv dir and check for the above files linked .eg cxcore210 check if there is some other name instead and replace accordingly.


Add these lines and tick
Add these foll commands to the linker command line
-lcxcore210 -lcv210 -lcvaux210 -lhighgui210 -lml210


Now go to Directories

first in Binaries Add path to opencv Bin folder
C:\OpenCV\bin
again change it according to your bin path

then go to Libraries Add path to opencv Lib folder
C:\OpenCV\lib
again change it according to your lib path


then go to C includes Add path to opencv Include folder
C:\OpenCV\include
again change it according to your include path

then go to C++ includes Add path to opencv Include folder
C:\OpenCV\include
again change it according to your include path


Now go to Environment Variables and edit path variable
and add Opencv/bin to path and save.
Again the bin path should be according to your install dir opencv path. change it accordingly.




click ok and your are done .
go to samples and run them.
if u get errors
Make sure you have selected operating compiler as openCV.

Project -Project options - Compiler

cheers

13 comments:

  1. Hi.. just a suggestion, use ctrl+alt+prtsc to take the screen shot of the current active window.

    ReplyDelete
  2. for a simple program i'm getting the error lik this..error: `Mat' undeclared (first use in this function)

    ReplyDelete
    Replies
    1. did u include the corresponding libraries .

      Delete
  3. hi thanx fr the tut
    ther is no lib or bin folder inside opencv instead
    i hav lib and bin inside each of these folders C:\opencv\build\x86\ mingw, vc9, vc10 ,vc11

    which one i hav to choose inside them der are no specific named files as cxcore etc

    am using opencv 2.4.5

    plz help am new to cv

    ReplyDelete
  4. hey bro while i am going to do this thing in netbeans javacv.im getting error that's java.exe not found in correct directory.do you have any idea about this.

    ReplyDelete
  5. Hey bro is it necessary that openCV library should be in C drive??

    ReplyDelete
  6. can you please explain this point clearly:
    "while doing so change the lib path( C:\OpenCV\lib) according to the path you have saved.GO to the lib folder in opencv dir and check for the above files linked .eg cxcore210 check if there is some other name instead and replace accordingly."

    cant get it clear,,wat is it???

    ReplyDelete
  7. I followed all these steps but i am facing the same problem #include "opencv.hpp" No such directory or file.Compilation error.

    ReplyDelete
  8. does this work for Opencv 3.2 as well?

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. The text written under Compiler Option=>compiler is Not clearly visible please write as a comment here

    ReplyDelete