OpenCV 3.4 Installation

You can also follow part of the tutorial here (follow up to step 8): https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv

1. Download the repository for OpenCV 3.4 here: https://github.com/opencv/opencv/tree/3.4

2. Unzip the folder and make a folder named “build” in its home directory. Open CMake GUI (https://cmake.org/download/). Select the source as the OpenCV file that you just downloaded, and the build as the build folder you just made.

12.png

3. Click Configure and uncheck BUILD-SHARED-LIBS.

13.png

4. Click Generate, using Visual Studio 2017 as your generator.

5. Click Open Project to open it in Visual Studio after it’s finished. Press Ctrl+Shift+B to build the solution.

6. To check if it’s installed correctly, open Windows Powershell and the Python environment. Import OpenCV by typing “import cv2”. If no errors come up, you’re good. You can also check which version of OpenCV you’ve installed by typing “cv2.__version__”. If there is an error, try copying and pasting the “cv2” folder into C:\Python27\Lib\site-packages.

14.png

7. To get OpenCV-Contrib, just type in “pip install opencv-contrib-python”. (If you haven’t installed pip yet, check out the pip tutorial and come back to this step). OpenCV-Contrib is required for using more advanced and/or beta features of OpenCV, like object tracking. I’m not sure how you can verify the installation easily from the command line (it’ll just be part of OpenCV), but methods like cv2.selectROI will work if it’s installed correctly.