CONFIGURE CODEBLOCK WITH OPENCV
ref:http://jonniedub.blogspot.co.id/2013/01/setting-up-codeblocks-ide-for-use-with.html?showComment=1454444260714#c506464558721086998
http://blog.csdn.net/mummyding/article/details/49804921
1. Create new project:
File -> New -> Project…-> Find ‘OpenCV Project’ -> click ‘Go’ -> Next -> Write Project Title and the Path ->
Compiler: GNU GCC Compiler -> Finish
2. Default opencv template (main.cpp in /Sources/ directory) is created. Here is main.cpp:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <opencv2/core/core.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> using namespace cv; int main(int argc, char *argv[]) { Mat img = imread("lena.jpg", CV_LOAD_IMAGE_COLOR); if(img.empty()) return -1; namedWindow( "lena", CV_WINDOW_AUTOSIZE ); imshow("lena", img); waitKey(0); return 0; } |
3. Its time to configure this project so it’d be linked to opencv library.
From eclipse configuration above, we get the libraries path by using:
pkg-config –cflags opencv
pkg-config –libs opencv
We’ll do the same here:
a. Right click the Project Name ‘OpenCV’ -> Build Options -> Click the Project name (OpenCV) DO NOT the ‘Debug’ ->
Search directories tab -> Compiler tab -> click Add -> fill with: /usr/local/include/opencv
b. then click Linker tab -> click Add -> fill with: /usr/local/lib
c. Then at Linker settings tab -> In Link Libraries, Add this (one by one):
opencv_core
opencv_imgcodecs
opencv_highgui
In Others linker options:, add:
opencv-config --ldstaticflags
d. click OK
4. Test it!
Right click the Project name ‘OpenCV’ -> Build
make sure everything okay
Then click ‘Run’ (the green arrow) or from Build -> Run
SHORTCUT: F9 (Build and Run at ONCE!)