I'm using Windows 10 with python 3 installed. I downloaded the opencv 4 source code and compiled it from its cmake file successfully. I also run the install.vcproj to install it.
The install path is like this:
C:\OpenCV
bin
etc
include
sample
x86
vc15
bin
lib
Then I manually add C:\OpenCV\x86\vc15\bin to the environment variable of path, so that I can run the compiled c++ samples.
Now I want to run some python samples, in C:\OpenCV\samples\python, for example, the opencv_version.py, but I have a ModuleNotFoundError at this line of code:
import cv2 as cv
It seems that my locally compile opencv can't be found by python.
I know that if I want to use the precompiled opencv, I just run pip3 install opencv-python, but now I don't want to use the precompiled version, I want to use my own compiled opencv for python.
Questions:
- Do I need to change some cmake configurations during my build of opencv to enable its python binding?
- How do I add my own opencv to the path of python, which path (in my case, which
C:\OpenCVsub-folder) should be added?