March 2020
Intermediate to advanced
366 pages
9h 8m
English
The BaseLayout constructor accepts an ID (-1), a title string ('Fun with Filters'), a video capture object, and an optional argument that specifies the number of frames per second. Then, the first thing to do in the constructor is to try to read a frame from the captured object in order to determine the image size:
def __init__(self, capture: cv2.VideoCapture, title: str = None, parent=None, window_id: int = -1, # default value fps: int = 10): self.capture = capture
_, frame = self._acquire_frame() self.imgHeight, self.imgWidth = frame.shape[:2]
We will use the image size to prepare a buffer that will store each video frame as a bitmap and to set the size of the GUI. Because we want to display a bunch of ...