Active2 years, 11 months ago
Step by step instruction for installing OpenCV 3 on Windows. Install OpenCV 3 on Windows. This is used by CMake to configure OpenCV_LIBS and OpenCV_INCLUDE_DIRS. Installing OpenCV (Last updated 1/16/2018) Dr. This guide will illustrated how to install the OpenCV library as well as get it ready for use with your IDE. This is certainly not the only way to set things up, but it does have the virtue for working for me in the past. Specifically, this guide covers: CMake 3.10.1; OpenCV 3.4.0. CMake will generate a set of Makefiles that can build OpenCV by calling make, and later installed by calling make install as root. As it can take a long time to build all of OpenCV, there is an option to parallelize parts of it by including the -j flag, followed by the number of threads that should be used. O Run the executable and install to ^C: OpenV2.3. NOTE: From this point, the root directory for OpenCV will be called '$( VROOT) _. O Open the new folder and the inside folder opencv. Ut all folders from inside opencv and move t hem back a folder to '$( VROOT). You can remove the opencv folder.
CMake will generate a set of Makefiles that can build OpenCV by calling make, and later installed by calling make install as root. As it can take a long time to build all of OpenCV, there is an option to parallelize parts of it by including the -j flag, followed by the number of threads that should be used.
I wish to use opencv for my project(c++) since it has lot of functionality so i tried to install opencv but i couldn#t undestand the things which had been mentioned in their user guide. according to their instruction, i tried to install Cmake but i couldn't. so how to use --prefix= option to specify a custom installation directory for CMake.according to their instruction i should do following steps;1. run the bootstrap script from within the CMake source directory or any other build directory of your choice. 2. Once this has finished successfully, run make and make install.So basically it's the same as you may be used to from autotools-based projects:
$ ./bootstrap; make; make install
but i don't know how to do this. how to run bootstrap script and where? please need helps...thanks
akiaki753 gold badges5 silver badges16 bronze badges
1 Answer
If you are planning on using Xcode to develop:
- Download Xcode
- Download and install mport: https://www.macports.org/install.php
- Download OpenCV and move it to your desired directory
- Once you moved OpenCV to a directory you’re happy with, cd into this directory and create a folder called ‘build’ with the mkdir command.
- Cd into this new folder and run cmake -G “Unix Makefiles” This command will start installing what OpenCV needs to run.
- Once it’s done, run “make -j8” in your Terminal and ‘sudo make install’.
Everything should now be installed. If you check inside your build > lib folder, you should see all the frameworks that have been installed.
- Open Xcode and create a new project by clicking on File > New > Project.
- Go to OSX > Application and select ‘Command Line Tool’.
- In the next window, make sure the language selected is C++ and enter the project name you’d like. For example ‘OpenCV Tutorial’.
Your project window will then open, select the project file (the file at the top of your project), and follow these steps:
a. At the top, select Build Settings and search for Search Pathsb. Change the Always Search User Paths to true.c. Change the Header Search Paths to usr/local/include.d. Change Library Search Paths to usr/local/lib.e .In the search field, remove your previous search and scroll down until you find the Linking section.f. Double click on Other Linker Flags, click on the + button and add:
-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab
All of the previous steps will allow Xcode to know where to look for when you import a library in your code.
Finally, go to your Xcode preferences, select Locations Tab, click Advanced and change the location button from Unique to Legacy.
You should be good to go now!
If you're okay running your applications from the terminal, follow this:
- Download Cmake gui.
- Download and unzip OpenCV somewhere.
- Create two new folders inside of the openCV directory, one called staticlibs and the other sharedlibs.
- Build the staticlibs like so:Open CMake.Click Browse Source and navigate to your openCV folder.Click Browse Build and navigate to your StaticLib Folder.Click the configure button. You will be asked how you would like to generate the files. Choose Unix-Makefile from the Drop Down menu and Click OK. CMake will perform some tests and return a set of red boxes appear in the CMake Window.
You will need to uncheck and add to the following options.
Uncheck
BUILD_SHARED_LIBS
Uncheck BUILD_TESTS
Add an SDK path to CMAKE_OSX_SYSROOT
, it will look something like this “/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk”.Add x86_64 to CMAKE_OSX_ARCHITECTURES
, this tells it to compile against the current systemUncheck WITH_1394
Uncheck WITH_FFMPEG
Click Configure again, then Click Generate.- When the application has finished generating, Open Terminal and type the following commands to install the static libs on your computer.
- cd <path/to/your/opencv/staticlibs/folder/>- make (This will take awhile)- sudo make install
- Build shared libraries the same way with some minor changes as following:Open CMake.Click Browse Source and navigate to your openCV folder.Click Browse Build and navigate to your SharedLib Folder.Click the configure button. You will be asked how you would like to generate the files. Choose Unix-Makefile from the Drop Down menu and Click OK. CMake will perform some tests and return a set of red boxes appear in the CMake Window.You will need to uncheck and add to the following options.
Check BUILD_SHARED_LIBSUncheck
BUILD_TESTS
Add an SDK path to CMAKE_OSX_SYSROOT
, it will look something like this “/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk”.Add x86_64 to CMAKE_OSX_ARCHITECTURES
, this tells it to compile against the current systemUncheck WITH_1394
Uncheck WITH_FFMPEG
Click Configure again, then Click Generate.Once it's done running enter the following in the terminal:
- cd <path/to/your/opencv/SharedLibs/folder/>- make (This will take awhile)- sudo make install
You're done! Now to make an application do the following:
Step 1:
Create a new folder somewhere on the computer.Inside the folder, create a CMakeLists.txt file then create a FileName.cpp file.
Step 2:
Write code. Save your file.
Step 3:Open the CMakeLists.txt file then add the following text.
cmake_minimum_required(VERSION 2.8) project( BlurImage ) find_package( OpenCV ) include_directories( ${OpenCV_INCLUDE_DIRS} ) add_executable( FileName FileName.cpp ) target_link_libraries( FileName ${OpenCV_LIBS} )
Step 4: Open Terminal and navigate to your applications directory.
- cd <path/to/application/folder> - /Applications/CMake.app/Contents/bin/cmake . - make
To run type
Then type ./FileName
in the terminal.Source:http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
GelaGela
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.