- 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.
推薦閱讀
- UNIX編程藝術
- Vue.js前端開發基礎與項目實戰
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- Redis Essentials
- JavaScript 程序設計案例教程
- C語言程序設計同步訓練與上機指導(第三版)
- Linux:Embedded Development
- 從零開始學C語言
- SQL Server 2008 R2數據庫技術及應用(第3版)
- Extending Unity with Editor Scripting
- 大學計算機基礎
- OpenCV Android Programming By Example
- Unity Android Game Development by Example Beginner's Guide
- Appcelerator Titanium:Patterns and Best Practices
- 編程的原則:改善代碼質量的101個方法