I've followed the documentation here:
https://docs.opencv.org/3.4.1/d5/de5/tutorial_py_setup_in_windows.html
The documentation lists two methods, but I can't get either of them to work. The first method, installing from prebuilt binaries, results in the error `ImportError: DLL load failed: The specified module could not be found.` when trying to `import cv2`.
The second method, building from source, is the desired method because my end goal is to tweak the build configuration for our use case (otherwise I'd just use https://pypi.org/project/opencv-python/). But I can't get this method to work either. The first 7 instructions go fine, here's my CMake output: https://gist.github.com/zcregan/83bb1e44400927351f697723cd701eb7
The next couple instructions are fine. At the 10th instruction there are no `BUILD_opencv_gpu*` entries, and there is no `BUILD_opencv_python` entry, but there is a `BUILD_opencv_python_bindings_generator` entry already enabled, so I just continue on. At instruction 12 there's no single `PYTHON_*` set of entries, there's two sets consisting of `PYTHON2_*` and `PYTHON3_*`. I'm using a fresh install of Python3, and CMake correctly filled in `PYTHON3_EXECUTABLE`, `PYTHON3_NUMPY_INCLUDE_DIRS`, and `PYTHON3_PACKAGES_PATH`, so I manually enter in `PYTHON3_INCLUDE_DIR` and `PYTHON3_LIBRARY` (there's a weird `PYTHON3_INCLUDE_DIR2` leftover so I leave that blank). I run CMake Configure again, and then Generate, here's the output: https://gist.github.com/zcregan/2df3f8c3e8dc3b69ee6fc84498d4b372
I then follow the remaining instructions, everything builds successfully, no errors or warnings, but then get the error `ModuleNotFoundError: No module named 'cv2'` when trying to `import cv2`.
I'm not seeing any python modules in the build directory, and the line `OpenCV modules:` > `Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz` in my CMake output leads me to believe that my issue is back in the CMake configuration.
Can anybody help me build and configure the Python bindings? I'll make a PR to update the documentation once I figure out how to do it. Much appreciated.
↧