Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用videoflow从视频url或usb摄像头读取?_Python_Python 3.x_Videoflow - Fatal编程技术网

Python 如何使用videoflow从视频url或usb摄像头读取?

Python 如何使用videoflow从视频url或usb摄像头读取?,python,python-3.x,videoflow,Python,Python 3.x,Videoflow,python库中有关于如何读取视频文件的内容,但如何从计算机中的usb设备读取视频?它刚刚添加到其中。你可以这样做。只需确保在代码中正确设置相机的设备id import videoflow import videoflow.core.flow as flow from videoflow.core.constants import REALTIME from videoflow.producers import VideoDeviceReader from videoflow.consumers

python库中有关于如何读取视频文件的内容,但如何从计算机中的usb设备读取视频?

它刚刚添加到其中。你可以这样做。只需确保在代码中正确设置相机的设备id

import videoflow
import videoflow.core.flow as flow
from videoflow.core.constants import REALTIME
from videoflow.producers import VideoDeviceReader
from videoflow.consumers import VideofileWriter

class FrameIndexSplitter(videoflow.core.node.ProcessorNode):
    def __init__(self):
        super(FrameIndexSplitter, self).__init__()

    def process(self, data):
        index, frame = data
        return frame

def main():
    output_file = "output.avi"
    device_id = 0
    reader = VideoDeviceReader(device_id)
    frame = FrameIndexSplitter()(reader)
    writer = VideofileWriter(output_file, fps = 30)(frame)
    fl = flow.Flow([reader], [writer], flow_type = REALTIME)
    fl.run()
    fl.join()

if __name__ == "__main__":
    main()