首页 > 解决方案 > 如何在python,opencv中的构造函数内部读取相机帧

问题描述

我陷入了一个问题。我想在放置在构造函数内的函数中读取相机帧。问题是视频流无法启动。窗户挂了。

代码

class MyCLass:
    def __init__(self. root):
        self.root = root
    
        def video_stream():
            print("[INFO] starting video stream...")
            vs = VideoStream(src=0).start()
            writer = None
            # time.sleep(2.0)

            # loop over frames from the video file stream
            while True:
                # grab the frame from the threaded video stream
                frame = vs.read()
                cv2.imshow("Frame", frame)

        video_stream()

标签: pythonopencv

解决方案


推荐阅读