This time it's all about setting up the mighty “pixel”-processing library OpenCV1 in the well-known IDE called Eclipse2. Before we get our hands dirty, I should mention that it will be a very brief post, since it is only a necessary preparation in order to get started with the next project coming up, dealing with mini robots doing penalty shootouts (← You surely don't wanna miss that ;)).
So nuff said, let's get started!
(In this tutorial I assume that you are using linux and have Eclipse already installed)
If you have already installed OpenCV, you can skip to point 3.
(In this tutorial I assume that you are using linux and have Eclipse already installed)
If you have already installed OpenCV, you can skip to point 3.
-
First get OpenCV from the link below. I used the latest version, which was 2.4.5 at that time.
-
Well done! Now unzip it, build it & install it.
> cmake .
> sudo make install
-
If the previous steps were successful, you are good to go! Now switch to Eclipse and create a new project. In my case it's called OpenCVLocalTest.
-
Next create a new source file (e.g. OpenCVLocalTest.cpp) and paste the following source. (This step is optional.)
#include <cv.h> #include <highgui.h> using namespace cv; int main(int argc, char** argv) { // create image. Mat image; // insert your image here (e.g. logo.png). image = imread("logo.png", 1); // test if image is loaded properly. if (!image.data) { printf("No image loaded\n"); return -1; } // create window with the size of the image. namedWindow("sciWave", CV_WINDOW_AUTOSIZE); imshow("sciWave", image); // close windows by pressing any key. waitKey(0); return 0; }
-
So now it gets serious! Open the properties dialogue for your newly created project and switch to “C/C++ Build” → “Settings”. Under “GCC C++ Compiler” → “Includes” you have to add the path to the OpenCV headers you want to include. They should be located in /usr/local/include/OpenCV/.
-
After that, you have to set the “Library search path (-L)”, located under “GCC C++ Linker” → “Libraries”, to the path of the folder containing the OpenCV libraries. (Normally located in /usr/local/lib/.)
-
The last part is to finally add all the libs, that you actually want to use in your project, in the “Libraries (-l)”-section.
-
Ready to roll? Press build all, insert an image and start the program!
Yeah, now we're finished with the boring preparations and about to rock! I hope it was helpful to you and I can't wait for your comments, so feel free to share your thoughts ;-)
References:
http://www.sciwave.com/
Abonnieren
Kommentare zum Post (Atom)
Hi, that's exactly what I was looking for!!! Thx
AntwortenLöschen