For the depth-camera version of Cameo
, let's create a new class, CameoDepth
, as a subclass of Cameo
. On initialization, a
CameoDepth
class creates a CaptureManager
class that uses a depth camera device (either CV_CAP_OPENNI
for Microsoft Kinect or CV_CAP_OPENNI_ASUS
for Asus Xtion, depending on our setup). During the main loop in run()
, a CameoDepth
function gets a disparity map, a valid depth mask, and a normal color image in each frame. The normal color image is used to estimate facial rectangles, while the disparity map and valid depth mask are used to refine the estimate of the facial region using createMedianMask()
. Faces in the normal color image are swapped using copyRect()
, with the faces' respective masks applied. Then, the destination frame is displayed, optionally with debug rectangles drawn overtop it. We can implement CameoDepth
in cameo.py
as follows:
class CameoDepth(Cameo): def __init__(self): self._windowManager = WindowManager('Cameo...