I've been into this problem for many hours and finally I've solved it, and I'll share with you (and for any body else) how to solve it.
Here are the steps:
1- Download CMAKE from the official website.
2- Download Visual Studio
3- Download OpenCV Sources.zip files.
4- Download OpenCV-contrib from github.
First, we'll create a directory and name it 'OpenCV', this directory will contain the 'opencv-x.x.x' and 'opencv_contrib-x.x.x' downloaded extracted files.
We'll also create a 'build' directory that will contain the new OpenCV build files.
- The next step is to run the CMake (cmake-gui) app.
- You should then
- locate the 'opencv-x.x.x' extracted folder in the directory we created 'OpenCV'.
- do the same for the 'build' folder.
- After doing that, click on 'Configure'
A popup window should appear, choose the suitable configurations
Wait for the progress bar to finish.
- Check the OPENCV_ENABLE_NONFREE, then click 'Configure' again and wait for the progress bar.
After it is done loading, click 'Generate', right next to 'Configure' button.
Congrats, you've done the first steps!
Okay, close the CMAKE (cmake-gui) app and go to the 'build' directory we created.
locate 'OpenCV.sln' and run it using Visual Studio.
Change vs build mode from 'Debug' to 'Release'.
On the right 'Solution Explorer' menu, locate 'CMakeTargets' >> 'ALL_BUILD', right click it and select 'Build'
Wait for it to build (it may take 5+ minutes)
Again, on the right 'Solution Explorer' menu, locate 'CMakeTargets' >> 'INSTALL', right click it and select 'Build'
- After it finishes loading, you can then use it, that's all!
Extra:
- You can freely uninstall any pre-installations of 'opencv-python' and 'opencv-contrib-python' via the the pip
pip uninstall opencv-python
pip uninstall opencv-contrib-python
$ python
>>> import cv2
>>> cv2.__version__
Hope this helps, thank you!