Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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 IP摄像机OpenCV图像读过_Python_Opencv_Image Processing_Camera - Fatal编程技术网

Python IP摄像机OpenCV图像读过

Python IP摄像机OpenCV图像读过,python,opencv,image-processing,camera,Python,Opencv,Image Processing,Camera,我很难用OpenCV和Python在RPI4(甚至在Mac上)上处理IP摄像头图像。我的项目是获取IP摄像机图像(RGB-1920 x 1080),并使用目标检测算法对其进行处理。我没有任何实时限制。如果我能每5分钟运行一次算法,那就太完美了 OpenCV版本:4.1.1 Python版本:3.6.5 首先,我用我之前录制的图像库(来自同一台摄像机)测试了算法。它非常有效 然而,当我试图使用视频流时,我得到了一个关于过度阅读的错误。我想,我应该对管理图像流的方式有问题 import cv2, t

我很难用OpenCV和Python在RPI4(甚至在Mac上)上处理IP摄像头图像。我的项目是获取IP摄像机图像(RGB-1920 x 1080),并使用目标检测算法对其进行处理。我没有任何实时限制。如果我能每5分钟运行一次算法,那就太完美了

OpenCV版本:4.1.1 Python版本:3.6.5

首先,我用我之前录制的图像库(来自同一台摄像机)测试了算法。它非常有效

然而,当我试图使用视频流时,我得到了一个关于过度阅读的错误。我想,我应该对管理图像流的方式有问题

import cv2, time

cap = cv2.VideoCapture(‘URL’)
if (cap.isOpened()== False):
        print("Error opening video stream or file")

sampleTime = 10 # in seconds
imgCounter = 0
startTime = time.time()

while True:
        ret, frameCaptured = cap.read()

        if time.time() - startTime >= sampleTime and ret == True:
                startTime = time.time()

                # Do some stuff here
                time.sleep(5)
                cv2.imshow('Captured Image', frameCaptured)
                imgCounter += 1
                print("Image:",imgCounter)

        if cv2.waitKey(1) & 0xFF == ord('q'):
                break

cap.release()
cv2.destroyAllWindows()
即使第一张图像正常录制,我也会系统地得到一个错误: 图片:1 [mjpeg@0x7ff6ac808000]未读8

然后变量“ret”变为False。
请注意,如果没有条件“ret==True”,我会在第二个图像上看到一个绿色区域,然后执行停止。

您可以发布您的完整错误吗?请检查您的格式-缩进在Python中很重要。很抱歉,缩进已修复。通过我发布的代码,我得到了:MacBookPro-…$python3~/Desktop/test.py>Image:1>[mjpeg@0x7f990f81ac00]超过了8。那么它永远不会停止,因为“ret=False”你解决了这个问题吗?我也经历了同样的@Pm22