How to streem video from blueos for opencv python

my code is below

import cv2

port = 5600
pipeline = ('udpsrc port={} ! '
            'application/x-rtp, payload=96 ! '
            'rtpjitterbuffer ! rtph264depay ! '
            'decodebin ! videoconvert ! '
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

if not cap.isOpened():
    print("Cannot open camera")
while True:
    # Capture frame-by-frame
    ret, frame =
    # if frame is read correctly ret is True
    if not ret:
        print("Can't receive frame (stream end?). Exiting ...")
    # Our operations on the frame come here
    gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    # Display the resulting frame
    cv.imshow('frame', gray)
    if cv.waitKey(1) == ord('q')t :
# When everything done, release the capture

result is “Cannot open camera”

i use blueOS ver 1.1


I managed to stream video images transmitted in udp by BlueOs using this python script (there is also a c++ version) from a topside computer.

Python script
C++ version

I hope it can help you.

1 Like

Hi @ktkt, welcome to the forum :slight_smile:

A couple of questions to clarify:

  1. Can you confirm that you have a video stream configured in BlueOS to point to port 5600 on the computer you’re running your OpenCV script on?
  2. Have you managed to receive the video stream using the commandline version of gstreamer, with an autovideosink element instead of the appsink element used in your script?
    • If that doesn’t work then it’s gstreamer that’s failing to receive the stream, not OpenCV.