我的任务是使用OpenCV处理来自海康威视IP cam的流式视频
我试试这个
“”“
cap = cv2.VideoCapture()
cap.open("rtsp://yourusername:yourpassword@172.16.30.248:555/Streaming/channels/1/")
还有这个
“”“
cam = Client('http://192.168.1.10', 'admin', 'password', timeout=30)
cam.count_events = 2
response = cam.Streaming.channels[101].picture(method='get', type='opaque_data')
for chunk in response.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
img = cv2.imread('screen.jpg')
cv2.imshow("show", img)
cv2.waitKey(1)
在第一种情况下,realtime和cap.read()之间有大约9-20秒的延迟。 我用这样一个“hack”解决了它,但没有结果
“”“
class CameraBufferCleanerThread(threading.Thread):
def __init__(self, camera, name='camera-buffer-cleaner-thread'):
self.camera = camera
self.last_frame = None
super(CameraBufferCleanerThread, self).__init__(name=name)
self.start()
def run(self):
while True:
ret, self.last_frame = self.camera.read()
“”“
第二种情况显示的帧延迟为1-2秒,这是可以接受的,但fps=1,这不是很好
是否有任何选项可以帮助您获得低延迟和正常fps的流
在nathancys的职位上我找到了工作解决方案。已经完成了。 我在我的案例中使用了简单的修改他的代码来获得主函数中的框架
相关问题 更多 >
编程相关推荐