【发布时间】:2018-10-18 17:28:41
【问题描述】:
首先,我有 Python 3,其中包含 Gstreamer 库。
print(cv2.getBuildInformation())
它在 Gstreamer 旁边显示 YES。
这是在 RaspberryPi 3 中使用 gstreamer 的发射器代码:
gst-launch-1.0 v4l2src device="/dev/video0" ! video/x-raw,width=320,height=240 ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! udpsink host='my ip address' port=10000
我将使用 Python 代码来确定形状、识别物体等。
这是我的 Python 代码:
import numpy as np
import cv2
def receive():
cap = cv2.VideoCapture("udpsrc port=10000 ! application/x-rtp,encoding-name=H264 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoconvert ! ximagesin ", cv2.CAP_GSTREAMER)
while True:
ret,frame = cap.read()
if not ret:
print('empty frame')
continue
cv2.imshow('receive', frame)
if cv2.waitKey(1)&0xFF == ord('q'):
break
cap.release()
receive();
但它总是显示空框。
当我在终端尝试这个命令时:
gst-launch-1.0 udpsrc port=10000 ! application/x-rtp,encoding-name=H264 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoconvert ! ximagesink
它工作得很好,所以问题出在我的 Python 端。
你有什么推荐的?
【问题讨论】:
-
在你的python代码中,你写了
ximagesin,也许这就是问题所在?