- OpenCV 4 with Python Blueprints
- Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
- 181字
- 2021-06-24 16:50:00
Understanding the GUI constructor
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 control buttons below the current video frame, we set the height of the GUI to self.imgHeight + 20:
super().__init__(parent, window_id, title,
size=(self.imgWidth, self.imgHeight + 20))
self.fps = fps
self.bmp = wx.Bitmap.FromBuffer(self.imgWidth, self.imgHeight, frame)
In the next section, we will build a basic layout for our application with a video stream and some buttons using wxPython.
推薦閱讀
- 計算機網絡
- Docker and Kubernetes for Java Developers
- JavaScript+DHTML語法與范例詳解詞典
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- C#編程入門指南(上下冊)
- 三維圖形化C++趣味編程
- Learning SAP Analytics Cloud
- R語言編程指南
- 精通Python設計模式(第2版)
- Linux Device Drivers Development
- 深入分布式緩存:從原理到實踐
- 好好學Java:從零基礎到項目實戰
- Python3.5從零開始學
- 軟件測試教程
- Applied Deep Learning with Python