Home > Back-end >  How can I modify the OpenCV installation path as the one built from source instead of the one instal
How can I modify the OpenCV installation path as the one built from source instead of the one instal

Time:07-24

I built the OpenCV from the source to access GPU inference on Cuda using this great tutorial on windows. I tested the yolov3 inference (using cv2.dnn method) on GPU and it worked fine.

but after I installed another package named mediapipe using pip, the cv2 throw an error DLL load failed error when importing cv2, which of course is because of the fact that mediapipe installation also includes the opencv-python-contrib package.

Now I was wondering if there is any probable solution to fix this problem that avoids building OpenCV again from the source and does the things all over again.

I would appreciate it if you could specify solutions in detail.

CodePudding user response:

OK, I fixed the problem using these steps:

  1. after activating the environment, I uninstalled both opencv-python and opencv-python-contrib using pip. please note that mediapipe was not removed.
  2. I rebuilt the OpenCV library by setting the python interpreter in this environment as the OpenCV CmakeListVars file which can be done using CMake software.
  3. at the end both mediapipe and OpenCV ran with no issue.

So I did not find any shortcut to this issue, and we should run all the building process again.

  • Related