python opencv

保存直播流生存逐个图片

import cv2
from threading import Thread

class ThreadedCamera(object):
    def __init__(self, source = 0):

        self.capture = cv2.VideoCapture(source)

        self.thread = Thread(target = self.update, args = ())
        self.thread.daemon = True
        self.thread.start()

        self.status = False
        self.frame  = None

    def update(self):
        while True:
            if self.capture.isOpened():
                (self.status, self.frame) = self.capture.read()

    def grab_frame(self):
        if self.status:
            return self.frame
        return None  


if __name__ == '__main__':
    stream_link = "http://joy-oclive.linkv.fun/yolo/16938082183952747665.flv?wsSecret=a487d5c24d0e63af58717f2fe323b5ba&wsABStime=64f602fa"
    streamer = ThreadedCamera(stream_link)

    while True:
        frame = streamer.grab_frame()
        if frame is not None:
            cv2.imshow("Context", frame)
        cv2.waitKey(1) 

基于OpenCv的视频流处理方法_opencv处理视频流_北溪入江流的博客-CSDN博客

Python CV连续多帧的图像文件夹合成视频(代码) - 知乎

 

参考:

python - OpenCV real time streaming video capture is slow. How to drop frames or get synced with real time? - Stack Overflow

你可能感兴趣的:(python,开发语言)