Setting up OpenCV in Eclipse

Originalsource: http://carrierfrequency.blogspot.com/2011/05/opencv-22-in-windows-using-eclipse-ide.html

 

The latest release of OpenCV (version 2.2) has undergonedramatic changes to the library. Because of these changes, my olderguide is now outdated. For OpenCV version 2.2, please use thisguide.

First download and setup the basics:
  • Get MinGW
  • Download Eclipse C/C++ IDE
Note: I have a tutorial on these two steps already so justhead over HERE for more info.

  • Next download/install OpenCV 2.2
  • Now launch Eclipse and start a new project by going to:
  1. File->New->C++ Project (or File->New->CProject)
  2. Give your project a name in the "Project name" box
  3. Select the "Hello World" option under the "ProjectType" section under the"Executable" folder. I recommendthis over the "Empty Project" as it creates the c/c++ filefor you instead of having to do it manually (it also creates a"src" folder and a"Debug" folder which helps keepthings a little more organized)
  4. Make sure the "MinGW" Toolchain is selected in the"Toolchains" section
  5. Hit NEXT
  6. Fill in your Author and other file information, then hitNEXT
  7. In the next window select "Advanced settings...". Thiswill bring you to the "Project Settings" which can always beaccessed later by going to Project->Properties
  8. Under the "C/C++ Build" Section go to the"Settings" and select the "Tool Settings"Tab. Thenselect the "Includes" folder (on older versions of eclipseit is the "Directories" folder) in the GCC Compiler branchand add the opencv include directory to Include paths (-I):"C:\OpenCV2.2\include\". Of course, change C:\OpenCV2.2 tomatch the installed path that you used.
  9. Now, under the MinGW Linker select the"Libraries" folder and add the following to the Libraries(-l) section (note not all of these are necessarily needed foryour project but these are all the libraries available in opencvversion 2.2):
  • opencv_calib3d220
  • opencv_contrib220
  • opencv_core220
  • opencv_features2d220
  • opencv_ffmpeg220
  • opencv_flann220
  • opencv_gpu220
  • opencv_highgui220
  • opencv_imgproc220
  • opencv_legacy220
  • opencv_ml220
  • opencv_objdetect220
  • opencv_ts220
  • opencv_video220
In most cases you will only need opencv_core220 andopencv_highgui220 to get started
 
(Add NOTE:You need to change the namesaccording to the version of opencv you are using)

NOTE: Versions 2.2 and later postfix the librariesnames with a three digit number that corresponds to the version ofOpenCV that you are linking to.

FINALLY, under the "Library search path (-L)" sectionadd:
  • "C:\OpenCV2.2\lib"
  1. Hit OK when done
  2. Hit Finish to create and start the Project
Write up a simple program to test if opencv works properly. You canuse this EXAMPLE CODE I made to test if your videocamera and environment are working properly.

NOTE: The way this guide was written will require you to use a relative path to specify theheader files you wish to include. OpenCV breaks up the library intotwo sections, "legacy libraries" and "new libraries".

If you wish to specify one of the new opencv libraries use thefollowing format:

#include "opencv2\[subfolder]\[library.hpp]"

ADDITIONALLY, if you wish to include all of the primaryopencv2 header files in a project you can use:

#include "opencv2\opencv.hpp"

Note: opencv.hpp does not include every library in OpenCV2.2.It may be helpful for you to view the "opencv.hpp" library (locatedby default in: C:\OpenCV2.2\include\opencv2\opencv.hpp) to see whatis included and how you can reference the new libraries in yourcode. To see the complete list of libraries available, go to"C:\OpenCV2.2\include\" and browse around the directory.

Legacy libraries can be defined by: #include"opencv\[library.hpp]"


If you get an error, during compile time, pertaining to:
__exchange_and_add
Then visit this page and follow the instructions under:
Building on Windows using MinGW3.4.5
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值