February 2020
Intermediate to advanced
372 pages
9h 26m
English
Now that we have high-level functions and classes for several filters, it is trivial to apply any of them to the captured frames in Cameo. Let's edit cameo.py and add the lines that appear in bold in the following excerpts. First, we need to add our filters module to our list of imports, as follows:
import cv2import filtersfrom managers import WindowManager, CaptureManager
Now, we need to initialize any filter objects we will use. An example of this can be seen in the following modified __init__ method:
class Cameo(object): def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager( cv2.VideoCapture(0), self._windowManager, True) self._curveFilter = filters.BGRPortraCurveFilter() ...