Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/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 从ipcamera的实时视频源提取图像_Python_Opencv - Fatal编程技术网

Python 从ipcamera的实时视频源提取图像

Python 从ipcamera的实时视频源提取图像,python,opencv,Python,Opencv,我想使用opencv每5分钟从网络摄像头实时视频源中提取一次图像。我有下面的代码从视频中提取。但我不知道如何为来自ipcamera的实时视频流做到这一点 下面的代码用于每5秒从有效视频中获取一幅图像 import cv2 videoFile = "folder-path" cap = cv2.VideoCapture(videoFile) success, image = cap.read() success = True count = 0 while success: # Ca

我想使用opencv每5分钟从网络摄像头实时视频源中提取一次图像。我有下面的代码从视频中提取。但我不知道如何为来自ipcamera的实时视频流做到这一点

下面的代码用于每5秒从有效视频中获取一幅图像

import cv2

videoFile = "folder-path"
cap = cv2.VideoCapture(videoFile)
success, image = cap.read() 
success = True
count = 0

while success:
    # Capture frame-by-frame
    cap.set(cv2.CAP_PROP_POS_MSEC,(count*1000)
    success, image = cap.read()
    cv2.imwrite("file path/frame%d.jpg" % count, image)
    count = count + 5
cv2.VideoCapture()
与您关心的相机索引一起使用。如果您只有一个摄像头,
cv2.VideoCapture(0)
就可以了。如果有多个,则需要增加索引,直到访问正确的相机

此代码将每5分钟从照相机0捕获一帧:

camera = cv2.VideoCapture(0)   # start a connection to the camera
ret, frame = camera.read()     # read a frame
cv2.waitKey(300000)            # wait 5 minutes

你能每5分钟截屏一次吗?你知道如何在OpenCV中打开网络摄像头吗?而不是使用
cv2.VideoCapture('path/to/video/file')
使用
cv2.VideoCapture(0)