OpenCV facial mocap Python problems - Blender 2.82

I’ve tried to follow this OpenCV facial mocap tutorial:
Anybody who has managed to get it working on Win 10 64-bit, please help!

I have installed opencv and dlib into the Blender 2.82 local Python directory.
Everything seems to be working fine but I get this error:

 line 83, in modal
cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

No matter what I do with that Python script on my Win 10 PC, I cannot get the camera window to popup and show the video feed.
I have tested the camera and Opencv from within Blender 2.82, and they work fine, I have used this peace of code and it pops up a window and shows my video feed, no problems:

 import cv2
 vc = cv2.VideoCapture(0)
 if vc.isOpened(): # try to get the first frame
     rval, frame =
     rval = False
 while rval:
     cv2.imshow("preview", frame)
     rval, frame =
     key = cv2.waitKey(20)
     if key == 27: # exit on ESC

Any help will be greatly appreciated - I am pulling my hair for the second day now!
I have contacted the author, but didn’t get any replies so far.

PH Bob
Minion World

For anyone who had the same issue (on windows 10) , I solved it by replacing cv2.VideoCapture(0) by cv2.VideoCapture(0+CAP_DSHOW) as suggested here:

Hi, can you go through the step syou took to successfully install the libraries. Mine kept bombing out at the dlib stage. It would be good to get this working so I can import opencv.


sorry man, it was long time ago, don’t remember exact steps. Generally, I just paid attention to the video. The guy explained the installation process in great detail. Make sure you are in the correct directory when you run the commands. It was also too slow on Win 10. I put this on hold, as I found an easier way to animate my models’ mouth.

1 Like