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

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.

主站蜘蛛池模板: 长治县| 蓬安县| 台南市| 和平区| 卢龙县| 教育| 嵊泗县| 黄山市| 手游| 教育| 板桥市| 潢川县| 临清市| 绍兴县| 木兰县| 行唐县| 四会市| 梅河口市| 沙河市| 图木舒克市| 克山县| 富蕴县| 当阳市| 阜南县| 家居| 龙川县| 巍山| 原平市| 镇巴县| 北票市| 洛阳市| 连州市| 田东县| 健康| 乾安县| 万宁市| 张掖市| 泸溪县| 蒲江县| 三原县| 汽车|