如何从 wifi 摄像头压缩格式获取 http 流:python 上的 h.264?
How to get http stream from wifi camera compressed format: h.264 on python?
喂!我正在为学校开展一个项目,该项目使用使用 H.264 压缩格式的高清眼镜 Wifi 摄像头。我已经阅读了很多关于如何从相机获取帧的文档,但我不应该解决我的问题。我的代码如下所示:
import cv2
while True:
cap = cv2.VideoCapture('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')
ret, frame = cap.read()
print(frame)
我只想看到它能正确获取帧,但它会丢弃这样的错误:
[h264 @ 0x1e0a100] non-existing PPS 0 referenced
[h264 @ 0x1e0a100] non-existing PPS 0 referenced
[h264 @ 0x1e0a100] decode_slice_header error
[h264 @ 0x1e0a100] no frame!
非常感谢您的帮助!谢谢! :D
在评论的帮助下,我可以解决我的问题,并且可以正常工作,但会丢失一些初始帧。
import cv2
from threading import Thread
import time
url = ('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')
class VideoStream(object):
def __init__(self,url = ('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')):
self.capture = cv2.VideoCapture(url)
self.thread = Thread(target=self.update, args=())
self.thread.daemon = True
self.thread.start()
def update(self):
while True:
if self.capture.isOpened():
(self.status, self.frame) = self.capture.read()
time.sleep(.01)
def show_frame(self):
cv2.imshow('frame', self.frame)
key = cv2.waitKey(1)
if key == ord('q'):
self.capture.release()
cv2.destroyAllWindows()
exit(1)
if __name__ == '__main__':
video_stream = VideoStream()
while True:
try:
video_stream.show_frame()
except AttributeError:
pass
从这里复制 link:Video Streaming from IP Camera in Python Using OpenCV cv2.VideoCapture
喂!我正在为学校开展一个项目,该项目使用使用 H.264 压缩格式的高清眼镜 Wifi 摄像头。我已经阅读了很多关于如何从相机获取帧的文档,但我不应该解决我的问题。我的代码如下所示:
import cv2
while True:
cap = cv2.VideoCapture('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')
ret, frame = cap.read()
print(frame)
我只想看到它能正确获取帧,但它会丢弃这样的错误:
[h264 @ 0x1e0a100] non-existing PPS 0 referenced
[h264 @ 0x1e0a100] non-existing PPS 0 referenced
[h264 @ 0x1e0a100] decode_slice_header error
[h264 @ 0x1e0a100] no frame!
非常感谢您的帮助!谢谢! :D
在评论的帮助下,我可以解决我的问题,并且可以正常工作,但会丢失一些初始帧。
import cv2
from threading import Thread
import time
url = ('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')
class VideoStream(object):
def __init__(self,url = ('http://admin:@192.168.10.1/videostream.asf?user=admin&pwd=')):
self.capture = cv2.VideoCapture(url)
self.thread = Thread(target=self.update, args=())
self.thread.daemon = True
self.thread.start()
def update(self):
while True:
if self.capture.isOpened():
(self.status, self.frame) = self.capture.read()
time.sleep(.01)
def show_frame(self):
cv2.imshow('frame', self.frame)
key = cv2.waitKey(1)
if key == ord('q'):
self.capture.release()
cv2.destroyAllWindows()
exit(1)
if __name__ == '__main__':
video_stream = VideoStream()
while True:
try:
video_stream.show_frame()
except AttributeError:
pass
从这里复制 link:Video Streaming from IP Camera in Python Using OpenCV cv2.VideoCapture