ITeye博客

Opencv+Mingw+Eclipse

up2pu · 2013-10-20 14:51 · Opencv · 开源软件 · Markdown

http://www.argong.com/docs/how-to-OpenCV-2.2.0.pdf http://blog.eyalarubas.com/2012/10/23/opencv-installation-on-windows-netbeans-mingw/ http://nenadbulatovic.blogspot.com/2013/07/configuring-opencv-245-eclipse-cdt-juno.html

通过OpenCV例子生成的exe,使用Opencv直接下载的dll都不能用。需要自己重新编译生成。

Include: "C:\opencv245\build\include" "C:\opencv245\build\include\opencv2" "C:\opencv245\build\include\opencv" Library: opencv_core245 opencv_highgui245 opencv_imgproc245 "E:\software\dev\OpenCV245MinGW\x86\lib"(改成自己编译生成的目录)

PATH添加: E:\software\dev\OpenCV245MinGW\x86\bin;C:\MinGW\bin;E:\software\dev\cmake-2.8.12-win32-x86\bin;


Configuring OpenCV 2.4.6, Eclipse CDT (Juno), MinGW (x86) on Windows 7 After many trials and errors I decided to follow this tutorial and to compile my own binaries as it seems that too many people are complaining that precompiled binaries are NOT working for them. Eclipse CDT Juno was already installed.

My procedure was as follows:

  1. Download and install MinGW and add to the system PATH with c:/mingw/bin

  2. Download cmake from http://www.cmake.org and install it

  3. Download OpenCV2.4.6 Windows version

  4. Install/unzip Opencv to C:\OpenCV246PC\ (README,index.rst and CMakeLists.txt are here with all subfolders)

  5. Run CMake GUI tool

  6. Choose C:\OpenCV246PC\ as source

  7. Choose the destination, C:\OpenCV246MinGW\x86 where to build the binaries

  8. Press Configure button, choose MinGW Makefiles as the generator. There are some red highlights in the window, choose options as you need.

  9. Press the Configure button again. Configuring is now done.

  10. Press the Generate button.

  11. Exit the program when the generating is done.

  12. Exit the Cmake program.

  13. Run the command line mode (cmd.exe) and go to the destination directory C:\OpenCV246MinGW\x86

  14. Type "mingw32-make" (without quotation marks). You will see a progress of building binaries. If the command is not found, you must make sure that the system PATH is added with c:/mingw/bin. The build continues according the chosen options to a completion.

  15. In Windows system PATH (My Computer > Right button click > Properties > Advanced > Environment Variables > Path) add the destination's bin directory, C:\OpenCV246MinGW\x86\bin

  16. RESTART COMPUTER

  17. Go to the Eclipse CDT IDE, create a C++ program using the sample OpenCV code (You can use code from top of this topic).

  18. Go to Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes, and add the source OpenCV folder (including quotation marks) "C:\OpenCV246PC\build\include"

  19. Go to Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries, and add to the Libraries (-l) ONE BY ONE (this could vary from project to project, you can add all of them if you like or some of them just the ones that you need for your project):

opencv_calib3d246 opencv_contrib246 opencv_core246 opencv_features2d246 opencv_flann246 opencv_gpu246 opencv_highgui246 opencv_imgproc246 opencv_legacy246 opencv_ml246 opencv_nonfree246 opencv_objdetect246 opencv_photo246 opencv_stitching246 opencv_video246 opencv_videostab246

  1. Add the built OpenCV library folder (including quotation marks), "C:\OpenCV246MinGW\x86\lib" to Library search path (-L)

You can use this code to test your setup:

#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/opencv.hpp> #include

using namespace std; using namespace cv;

int main() {

Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); imshow("MyWindow", img);

waitKey(0); return 0; }

Don't forget to put image to the C:\ (or wherever you might find suitable, just be sure that eclipse have read acess.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。