官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 特克斯县| 神农架林区| 安丘市| 科尔| 西乌珠穆沁旗| 商洛市| 颍上县| 吉水县| 昌平区| 蓬溪县| 万荣县| 宁陵县| 辛集市| 惠东县| 博湖县| 衡山县| 华宁县| 佛学| 台南县| 灯塔市| 从化市| 桃园市| 太仆寺旗| 剑河县| 泸西县| 汉寿县| 蓬莱市| 遂川县| 鄱阳县| 泉州市| 克东县| 天长市| 仪征市| 阳谷县| 顺昌县| 浑源县| 澄江县| 宜昌市| 上虞市| 拉萨市| 双牌县|