Displaying a 4 channel transparent background image using OpenCV Videowriter

I want to write 4 channel video frames using videowriter

gst_out = "appsrc ! queue ! videoconvert ! videoscale method=0 ! xvimagesink"
vw = cv2.VideoWriter(gst_out, cv2.CAP_GSTREAMER, 0, 60, (2560, 720))
img = np.zeros((720,2560,4), dtype=np.uint8)
while True:

But I get the following error:

[ WARN:0] global /tmp/build_opencv/opencv/modules/videoio/src/cap_gstreamer.cpp (1631) writeFrame OpenCV | GStreamer warning: cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 3.

Is it possible to write a 4 channel image? I want to do this so I can later use videocompositor and place the opencv frames over another video feed.

By default it supports BGR format in OpenCV. 4-channel formats like RGBA or BGRx may not work in OpenCV. You may try to set caps:

gst_out = "appsrc ! video/x-raw,format=RGBA ! queue ! videoconvert ! videoscale method=0 ! xvimagesink"

If it does not work, 4-channel formats should not be supported.

No that didn’t work. I’m trying to do some image processing and create a transparent frame that I can overlay using videocompositor in a main gstreamer pipeline. I just need to dynamically overlay some text and some shapes onto the main video feed. Are there any alternatives you know of that can dynamically overlay shapes and text onto a gstreamer video?

A possible solution is to link to nvivafilter and use cairo APIs. Please refer to the patch:
Tx2-4g r32.3.1 nvivafilter performance - #16 by DaneLLL

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.