Let's revisit the Cameo project that we started in Chapter 2, Handling Files, Cameras, and GUIs. We can modify Cameo so that it applies filters to the captured images in real time. As in the case of our CaptureManager and WindowManager classes, our filters should be reusable outside of Cameo. Thus, we should separate the filters into their own Python module or file.
Let's create a file called filters.py in the same directory as cameo.py. We need the following import statements in filters.py:
import cv2 import numpy
import utils
Let's also create a file called utils.py in the same directory. It should contain the following import statements:
import cv2 import numpy import scipy.interpolate
We will be adding filter functions and classes to filters.py, while more general-purpose math functions will go in utils.py.