This is my first blog post so there can be many mistakes please help to to correct my mistakes and make this blog more impressive.Today I'm going to explain you how to Configure working environment for Digital image processing with C++.For that first we need to download few softwares and libraries.
Prerequisites
Java JRE
Windows 7 or later
Development tools
Here I use Cmake to compile my own binaries because lots of questions going on that precompiled binaries are NOT working for well.
Configuration
- Install MinGW C++ compiler. During installation , select “C++ Compiler” and “MSYS Basic System” for installation
- Add system PATH to "c:/mingw/bin" (Right click on my computer-> Properties->Advance system settings->Environment variable -> select path and click edit) example
- Install Cmake
- Install/unzip Opencv to C:\OpenCV\
- Run cmake GUI tool
- Choose C:\OpenCV\ as source
- Choose the destination, C:\OpenCV\x86 ,This is where to build the binaries
- Press Configure button, choose MinGW Makefiles as the generator.(then in red highlighted area We can choose many options but it's better to use default options if you are beginner)
- Press the Configure button again then press the Generate button
- Exit the cmake program when the generating is done
- Run the command line mode (cmd.exe) and go to the destination directory C:\OpenCV\x86 (type :- cd /OpenCV\x86)
- Type "mingw32-make". You can see a progress of building binaries. If the command is not found error occur problem is in system path (step 2)
- Add system PATH to C:\OpenCV\x86\bin (similar as step 2)
- Restart Computer
- Extract the downloaded Eclipse and run it
- Creating a new C++ Project from the File and New menu
- Select “Hello World C++ Project” under Executable for the Project Type, and MinGW GCC for the Toolchain of your New C++ Project. Type a Project Name and click the Finish button.
- Add “-static-libgcc -static-libstdc++” as Linker flags for your new project. This text should be added to the Linker flags field, which can be found by right-clicking on the new Project in the Project Explorer and clicking on Properties. Under the Project Properties, expand the C/C++ Build menu and click on Settings. Under the Tool Settings tab, expand the MinGW C++ Linker menu and click on Miscellaneous. Add the text to the Linker flags field, then click the Apply button. (More details ) about step 16 to 18
- Go to Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes, and add the source OpenCV folder "C:\OpenCV\build\include"
- Add the built OpenCV library folder, "C:\OpenCV\x86\lib" to Library search path (-L)
- 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,to run our simple project "opencv_core2410 " and "opencv_highgui2410 "):
- opencv_calib3d2410
- opencv_contrib2410
- opencv_core2410
- opencv_features2d2410
- opencv_flann2410
- opencv_gpu2410
- opencv_highgui2410
- opencv_imgproc2410
- opencv_legacy2410
- opencv_ml2410
- opencv_nonfree2410
- opencv_objdetect2410
- opencv_photo2410
- opencv_stitching2410
- opencv_video2410
- opencv_videostab2410
*2410 mean opencv version 2.4.10 therefore this will need to change if you use other version - Copy this code to your work place
#include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> using namespace std; using namespace cv; int main() { Mat img=imread("c:/example_image.png"); namedWindow("cat",WINDOW_AUTOSIZE); imshow("cat",img); waitKey(0); return 1; }
(download this sample image and save it in c:/example_image.png) - Click Build Project under the Project menu, then click Run under the Run menu.
-
example_image.png will pop up !!!!!!!!!!!!!!
No comments:
Post a Comment