Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Using openCV 3.2.0
with CodeBlocks
David Hsu
Download the installers
• openCV 3.2.0 (opencv-3.2.0-vc14.exe)
http://opencv.org/downloads.html
• tdm-gcc (tdm64-gcc-5.1.0...
Get openCV
• http://opencv.org/downloads.html
• opencv-3.2.0-vc14.exe
Extract opencv320 under C:
• Extract to C:
• Extracting…
Create a new folder under
C:opencv
• New a folder “build_codeblocks” under C:opencv
Get tdm-gcc
• http://tdm-gcc.tdragon.net/download
• tdm64-gcc-5.1.0-2.exe
Install tdm-gcc
• Create a new TDM-GCC installation
• Create a MinGW-w64-based installation
• Next> ….
Get CodeBlocks
• http://www.codeblocks.org/downloads/26
• codeblocks-16.01-setup.exe (go without mingw)
Open CodeBlocks
• Settings -> Compiler-… :
In CodeBlocks
• Select “Toolchain executables”
• Check Compiler’s installation directory : C:TDM-GCC-64
If can’t find compiler executable
• Click “Reset defaults”
• Click OK for the Message of “Auto-detected to C:TDM-GCC-64”
Get CMake
• https://cmake.org/download/
• cmake-3.7.1-win64-x64.msi or cmake-3.7.1-win32-x86.msi
Install CMake
• Next …
Open CMake (cmake-gui)
• Browse Source to “C:/opencv/sources”
• Browse Build to “C:/opencv/build_codeblocks”
• Click “Conf...
Specify the generator
• Choose the generator : CodeBlocks-MinGW Makefiles
• Check “Use default native compilers”
• Click “...
BUILD_opencv_world
• Once configuring done, scroll down and search for
BUILD_opencv_world. Make the option checked.
• Conf...
Generate
• Configuring done  Generate  Generating done
OpenCV.cbp
• Go to “C:opencvbuild_codeblocks” and open “OpenCV.cbp”
Build
• Build the OpenCV project
Build
• Build finished without any error (It may take a while)
Retarget the build to install
• Build  Select target  install
Build again
•
Build again
• Build without errors
Select opencv and opencv2
• Copy from “C:opencvbuild_codeblocksinstallinclude”
• Paste to “C:TDM-GCC-64x86_64-w64-mingw32i...
Select libopencv_world320.dll.a
• Copy from “C:opencvbuild_codeblocksinstallx64mingwlib”
• Paste to “C:TDM-GCC-64x86_64-w6...
Select all
• Copy from “C:opencvbuild_codeblocksinstallx64mingwbin”
• Paste to “C:TDM-GCC-64bin”
Create a new project in CodeBlocks
• File  new  Project…
• Choose “Console application”
Project – C++
• Choose “C++”
Project – name and save to…
• Name the project
• Determine the directory where the project will be saved to
Project – GNU GCC Compiler
• Check the compiler
Codes in main.cpp
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namesp...
main.cpp
Build options
• Right click the project and choose “Build options…”
Linker settings
• Linker settings
• Add
opencv_world320
• Add library : opencv_world320
opencv_world320
• Make sure opencv_world320 has been added to Link libraries
lena.bmp
• Put the resource file “lena.bmp” under the same directory of
main.cpp
Build and run
• Build and run the cvTest project
Image show
• Congrats and enjoy
programming with openCV
Upcoming SlideShare
Loading in …5
×

Using openCV 3.2.0 with CodeBlocks

12,141 views

Published on

Installation instructions of openCV using version 3.2.0 with Code::Blocks

Published in: Software

Using openCV 3.2.0 with CodeBlocks

  1. 1. Using openCV 3.2.0 with CodeBlocks David Hsu
  2. 2. Download the installers • openCV 3.2.0 (opencv-3.2.0-vc14.exe) http://opencv.org/downloads.html • tdm-gcc (tdm64-gcc-5.1.0-2.exe) http://tdm-gcc.tdragon.net/download • CodeBlocks (codeblocks-16.01-setup.exe) http://www.codeblocks.org/downloads/26 • CMake (cmake-3.7.1-win64-x64.msi) https://cmake.org/download/
  3. 3. Get openCV • http://opencv.org/downloads.html • opencv-3.2.0-vc14.exe
  4. 4. Extract opencv320 under C: • Extract to C: • Extracting…
  5. 5. Create a new folder under C:opencv • New a folder “build_codeblocks” under C:opencv
  6. 6. Get tdm-gcc • http://tdm-gcc.tdragon.net/download • tdm64-gcc-5.1.0-2.exe
  7. 7. Install tdm-gcc • Create a new TDM-GCC installation • Create a MinGW-w64-based installation • Next> ….
  8. 8. Get CodeBlocks • http://www.codeblocks.org/downloads/26 • codeblocks-16.01-setup.exe (go without mingw)
  9. 9. Open CodeBlocks • Settings -> Compiler-… :
  10. 10. In CodeBlocks • Select “Toolchain executables” • Check Compiler’s installation directory : C:TDM-GCC-64
  11. 11. If can’t find compiler executable • Click “Reset defaults” • Click OK for the Message of “Auto-detected to C:TDM-GCC-64”
  12. 12. Get CMake • https://cmake.org/download/ • cmake-3.7.1-win64-x64.msi or cmake-3.7.1-win32-x86.msi
  13. 13. Install CMake • Next …
  14. 14. Open CMake (cmake-gui) • Browse Source to “C:/opencv/sources” • Browse Build to “C:/opencv/build_codeblocks” • Click “Configure”
  15. 15. Specify the generator • Choose the generator : CodeBlocks-MinGW Makefiles • Check “Use default native compilers” • Click “Finish”
  16. 16. BUILD_opencv_world • Once configuring done, scroll down and search for BUILD_opencv_world. Make the option checked. • Configure again
  17. 17. Generate • Configuring done  Generate  Generating done
  18. 18. OpenCV.cbp • Go to “C:opencvbuild_codeblocks” and open “OpenCV.cbp”
  19. 19. Build • Build the OpenCV project
  20. 20. Build • Build finished without any error (It may take a while)
  21. 21. Retarget the build to install • Build  Select target  install
  22. 22. Build again •
  23. 23. Build again • Build without errors
  24. 24. Select opencv and opencv2 • Copy from “C:opencvbuild_codeblocksinstallinclude” • Paste to “C:TDM-GCC-64x86_64-w64-mingw32include”
  25. 25. Select libopencv_world320.dll.a • Copy from “C:opencvbuild_codeblocksinstallx64mingwlib” • Paste to “C:TDM-GCC-64x86_64-w64-mingw32lib’’
  26. 26. Select all • Copy from “C:opencvbuild_codeblocksinstallx64mingwbin” • Paste to “C:TDM-GCC-64bin”
  27. 27. Create a new project in CodeBlocks • File  new  Project… • Choose “Console application”
  28. 28. Project – C++ • Choose “C++”
  29. 29. Project – name and save to… • Name the project • Determine the directory where the project will be saved to
  30. 30. Project – GNU GCC Compiler • Check the compiler
  31. 31. Codes in main.cpp #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace cv; using namespace std; int main() { Mat image1, image2; image1 = imread("lena.bmp", CV_LOAD_IMAGE_COLOR); // Read the file if (!image1.data) // Check for invalid input { cout << "Could not open or find the image" << std::endl; return -1; } image2 = imread("lena.bmp", CV_LOAD_IMAGE_GRAYSCALE); // Read the file if (!image2.data) // Check for invalid input { cout << "Could not open or find the image" << std::endl; return -1; } cout<<"opencv test"<<endl; namedWindow("Color Image", WINDOW_AUTOSIZE);// Create a window for display. imshow("Color Image", image1); // Show our image inside it. namedWindow("Gray Scale Image", WINDOW_AUTOSIZE);// Create a window for display. imshow("Gray Scale Image", image2); // Show our image inside it. waitKey(0); // Wait for a keystroke in the window destroyAllWindows(); return 0; }
  32. 32. main.cpp
  33. 33. Build options • Right click the project and choose “Build options…”
  34. 34. Linker settings • Linker settings • Add
  35. 35. opencv_world320 • Add library : opencv_world320
  36. 36. opencv_world320 • Make sure opencv_world320 has been added to Link libraries
  37. 37. lena.bmp • Put the resource file “lena.bmp” under the same directory of main.cpp
  38. 38. Build and run • Build and run the cvTest project
  39. 39. Image show
  40. 40. • Congrats and enjoy programming with openCV

×