Mac os, eclipse, open cv
1. install jdk-8u60-macosx-x642. install eclipse. download
3. install cmake.
3.1 download.(what is cmake? defenition inEnglish or Chinese)
3.2 open Terminal, use "/../../Desktop/cmake/bootstrap" , "make" and "make install"
problem: "file cannot create directory: /usr/local/doc/cmake-3.3.Maybe need administrative privileges."
solution: "sudo make install Instead of make install" ,and require password
4.install opencv
4.1 download
4.2 use command :(here we use commond to build a temporary folder, "build" )
# make a separate directory for building
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
4.3 enter the temporary folder (here is "build"), and type commond:
make
sudo make install
5. test on eclipse (step 1)
5.1 Start Eclipse. Just run the executable that comes in the folder.
5.2 Go to File -> New -> C/C++ Project
http://docs.opencv.org/_images/a0.png 5.3 Choose a name for your project (i.e. DisplayImage). An Empty Project should be okay for this example.http://docs.opencv.org/_images/a1.png 5.4 Leave everything else by default. Press Finish.
6. test on eclipse (step 2)
6.1 Your project (in this case DisplayImage) should appear in the Project Navigator (usually at the left side of your window).
http://docs.opencv.org/_images/a3.png 6.2 Now, let’s add a source file using OpenCV:
[*]
[*]
Right click on DisplayImage (in the Navigator). New -> Folder
http://docs.opencv.org/_images/a4.png
Name your folder src and then hit Finish
Right click on your newly created src folder. Choose New source file:
Call it DisplayImage.cpp. Hit Finish
http://docs.opencv.org/_images/a7.pngSo, now you have a project with a empty .cpp file. Let’s fill it with some sample code (in other words, copy and paste the snippet below):
#include <cv.h>
#include <highgui.h>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv, 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
7.
We are only missing one final step: To tell OpenCV where the OpenCV headers and libraries are. For this, do the following:
[*]
Go to Project–>Properties
[*]
In C/C++ Build, click on Settings. At the right, choose the Tool Settings Tab. Here we will enter the headers and libraries info:
[*]
In GCC C++ Compiler, go to Includes. In Include paths(-l) you should include the path of the folder where opencv was installed. In our example, this is/usr/local/include/opencv.
http://docs.opencv.org/_images/a9.png
Note
If you do not know where your opencv files are, open the Terminal and type:
pkg-config --cflags opencv
For instance, that command gave me this output:
-I/usr/local/include/opencv -I/usr/local/include
[*]
Now go to GCC C++ Linker,there you have to fill two spaces:
First in Library search path (-L) you have to write the path to where the opencv libraries reside, in my case the path is:
/usr/local/lib
Then in Libraries(-l) add the OpenCV libraries that you may need. Usually just the 3 first on the list below are enough (for simple applications) . In my case, I am putting all of them since I plan to use the whole bunch:
opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_flann
http://docs.opencv.org/_images/a10.png If you don’t know where your libraries are (or you are just psychotic and want to make sure the path is fine), type in Terminal:( download pkg-config)
pkg-config --libs opencv
My output (in case you want to check) was: .. code-block:: bash
-L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
Now you are done. Click OK
[*]
Your project should be ready to be built. For this, go to Project->Build all
In the Console you should get something like
http://docs.opencv.org/_images/a12.png If you check in your folder, there should be an executable there.
http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html
页:
[1]