[英]Changing gstreamer pipeline to opencv in python
I have successfully installed and built gstreamer on opencv. 我已经在opencv上成功安装并构建了gstreamer。 It says YES when i print(cv2.getBuildInformation()).
当我打印(cv2.getBuildInformation())时,它说是。
Gstreamer version: 1.14.0
opencv version: 3.4.5.20
Bumped into a wall for quite a while at the moment, was using the gstreamer pipeline. 目前,使用gstreamer管道撞到墙壁上已经有一段时间了。 It works wonderfully.
效果很好。
gst-launch-1.0 -v playbin uri=rtsp://admin:password@192.168.1.65:554/Streaming/Channels/400 uridecodebin0::source::latency=10
This is the python script I've written for the gstreamer pipeline. 这是我为gstreamer管道编写的python脚本。
import cv2
import numpy as np
pipe = '"rtspsrc location=\"rtsp://admin:password@192.168.1.65:554/Streaming/Channels/400" latency=10 ! appsink'
cap = cv2.VideoCapture(pipe)
if not cap.isOpened():
print('VideoCapture not opened')
exit(0)
while True:
ret, frame = cap.read()
if not ret:
print('empty frame')
break
cv2.imshow('display', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
I keep getting this error though, unable to troubleshoot what caused this. 我一直收到此错误,但无法解决造成此问题的原因。
gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Update: Found the answer by Fixing the pipeline using rtspsrc instead of playbin. 更新:通过使用rtspsrc而不是playbin修复管道找到了答案。
Opencv's VideoCapture is not able to take autovideoconvert
and autovideosink
. Opencv的VideoCapture无法使用
autovideoconvert
和autovideosink
。 A work around would be to use videoconvert
and appsink
when using rtspsrc but latency can't be adjusted. 解决方法是在使用
appsink
时使用videoconvert
和appsink
,但无法调整延迟。 However, if you want to adjust the latency you will need to use decodebin to decode instead of avdec_h264 但是,如果要调整延迟,则需要使用decodebin进行解码,而不是avdec_h264
eg gst-launch-1.0 rtspsrc location://admin:password@192.168.1.65:554 latency=20 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink
例如
gst-launch-1.0 rtspsrc location://admin:password@192.168.1.65:554 latency=20 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink
gst-launch-1.0 rtspsrc location://admin:password@192.168.1.65:554 latency=20 ! rtph264depay ! h264parse ! decodebin ! videoconvert ! appsink
NB: Pipeline will work in the python script but may not work in the command line. 注意:管道将在python脚本中运行,但在命令行中可能无法运行。
This is for RTSP with IP cameras! 这是用于带IP摄像机的RTSP!
Cheers. 干杯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.