# Revision history [back]

### How can I stream the output of my OpenCV python script (running on a RaspPi) to my computer?

Hi I have a Raspberry Pi running an OpenCV script I wrote in python that recognizes and highlights colored round objects. I can easily view the raw video stream of the Pi Camera using VLC player, but I need the output video (with the highlighted objects) of my OpenCV script instead.

After much research it seems GStreamer is what I need, but hours of internet search have yielded very little example code of how I can implement it. This is the relevant parts of my python script:

import cv2
from PiVideoStream import PiVideoStream

vs = PiVideoStream().start()

out = cv2.VideoWriter('appsrc ! videoconvert ! ''x264enc noise-reduction=10000 speed-preset=ultrafast tune=zerolatency ! ''rtph264pay config-interval=1 pt=96 !''tcpserversink host=INSERT.IP.HERE port=5000 sync=false', 0, 32.0, (320, 240))

while True:
"""OpenCV algorithm that is irrelevant"""
out.write(frame)
key = cv2.waitKey(1) & 0xFFif key == lord("q"):
breakout.release()
vs.release()
cv2.destroyAllWindows()


And from my understanding, I need to start the Gstreamer pipeline which I do this:

gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host = INSERT.IP.HERE port=5000

1. Should INSERT.IP.HERE be the IP of my computer I want to view the stream on? Or of my raspberry pi?
2. I've tried using VLC player to view the stream at tcp://INSERT.IP.HERE:5000/ to no avail, is this the proper way to view?
3. Do I need to enable the Gstreamer plugin for my build of OpenCV? cv2.getBuildInformation() currently has "NO" on GStreamer, but I assumed this was separate from simply installing GStream on my Pi?