First of all I have Python 3 with the Gstreamer library in it.
print(cv2.getBuildInformation())
It shows Gstreamer with YES next to it.
Here is the transmitter code using gstreamer in RaspberryPi 3:
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
and I will be using Python code to determine shapes, recognize objects, etc..
Here is my Python code:
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();
but it always shows empty frame.
When I tried this command in the terminal:
gst-launch-1.0 udpsrc port=10000 ! application/x-rtp,encoding-name=H264 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! videoconvert ! ximagesink
it works just fine, so the problem is on my Python end.
What do you recommend?