我正在使用一个类来访问我的网络摄像机。
不幸的是,它以不规则的间隔发生
self.capture.isOpened ()
=返回False。
似乎没有框架或连接了吗?
我在其他说明下再次尝试了IP Cam 初始化,但这也无法正常工作。
还有其他提示吗?
操作: 我在启动时从主程序调用该类
stream_link = "rtsp: // admin: PW@192.168.2.101: 554 / stream = 0"
video_stream_widget = VideoStreamWidget (stream_link)
Cam已初始化,效果很好
在课堂上,当我更新框架时,我尝试确定是否 self.capture.isOpened()= True为-如果不进行初始化。
在这里不时发生 self.capture.isOpened()= False返回
class VideoStreamWidget(object):
def __init__(self, src=0):
# Create a VideoCapture object
self.capture = cv2.VideoCapture(src)
# Start the thread to read frames from the video stream --
self.thread = Thread(target=self.update, args=())
self.thread.daemon = True
self.thread.start()
time.sleep(2.0)
print("init video steam")
print(self.thread)
def update(self):
# Read the next frame from the stream in a different thread
while True:
if self.capture.isOpened():
(self.status, self.frame) = self.capture.read()
else:
print("Frame Update nicht möglich")
print("Neu init")
stream_link = "rtsp://admin:PW@192.168.2.101:554/stream=0"
video_stream_widget = VideoStreamWidget(stream_link)
# give the camera some time to recover
time.sleep(10)
(self.status, self.frame) = self.capture.read()