<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hey Guennadi<div><br></div><div>GStreamer has the GstMeta API, which allows you to attach metadata to the buffers which, from your last email, seems to be what you need. If you are using GStreamer 1.20 or later you can use gst_buffer_add_custom_meta. On previous versions, you’ll need to implement your own meta. If you need an example, here’s an implementation that adds video-related metadata to the buffers:</div><div><br></div><div><a href="https://github.com/GStreamer/gst-plugins-base/blob/master/gst-libs/gst/video/gstvideometa.c">https://github.com/GStreamer/gst-plugins-base/blob/master/gst-libs/gst/video/gstvideometa.c</a></div><div><br><div dir="ltr">The meta approach is what I would personally go for. For completeness of the answer, there is a way to have elements within elements, it’s called a bin. Your element would inherit from GstBin and basically build a sub-pipeline.</div><div id="AppleMailSignature" dir="ltr"><br></div><div id="AppleMailSignature" dir="ltr">One final idea is to consider using a third party scaler in your element, opencv or libyuv, for example. Your transform_caps method would change, not only the format, but the size as well. Then on the transform_frame you’d call the scaler after your processing. however, i’d remain principled and avoid mixing the two responsibilities and go for the meta approach. </div><div id="AppleMailSignature" dir="ltr"><br></div><div dir="ltr">Michael</div><div dir="ltr"><br><blockquote type="cite">On 31 Jul 2021, at 02:42, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><span>Hi Michael,</span><br><span></span><br><span>On Mon, 19 Jul 2021, Michael Gruner wrote:</span><br><span></span><br><blockquote type="cite"><span>Glad it worked!</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>If you want to overlay a picture (like the thermal bar in that GIF), you</span><br></blockquote><blockquote type="cite"><span>can check the gdkpixbufoverlay</span><br></blockquote><blockquote type="cite"><span><https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-good/html/gst-plugins-good-plugins-gdkpixbufoverlay.html></span><br></blockquote><blockquote type="cite"><span>element. If you also want to add a border to the image so that the</span><br></blockquote><blockquote type="cite"><span>overlay doesn’t cover part of the image, you may look at the videobox</span><br></blockquote><blockquote type="cite"><span><https://gstreamer.freedesktop.org/documentation/videobox/index.html?gi-language=c></span><br></blockquote><blockquote type="cite"><span>element. By setting the “right” property to a negative value, you’ll add</span><br></blockquote><blockquote type="cite"><span>a black border to the right of the image.</span><br></blockquote><span></span><br><span>Thanks, I'll check those! Meanwhile I realised, that I have one more</span><br><span>difficulty with this: the image I'm getting from the camera is 32x24</span><br><span>pixels, so, if I just extend it similar to that GIF I still only have 24</span><br><span>pixels vertically which isn't a lot for temperature text :-) I usually add</span><br><span>a videoscale element to the pipeline after my conversion plugin, that</span><br><span>works well, but that doesn't help with that bar - I want to add it after</span><br><span>scaling, and the actual processing must happen before scaling, it must</span><br><span>access original camera data.</span><br><span></span><br><span>One approach I could take is write a second plugin to apply after scaling,</span><br><span>but apart from the image that plugin would need some additional data from</span><br><span>the first one - at least the temperature range. My current plan is to pass</span><br><span>those two numbers in metadata lines below the image and hope that those</span><br><span>numbers aren't modified by the videoscale plugin...</span><br><span></span><br><span>Are there better ways to achieve this? Can I "call" videoscale internally</span><br><span>in my conversion plugin, then I wouldn't need two plugins. Or can I pass</span><br><span>metadata in some way more robust than image pixels?</span><br><span></span><br><span>Thanks</span><br><span>Guennadi</span><br><span></span><br><blockquote type="cite"><blockquote type="cite"><span>On 18 Jul 2021, at 05:09, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>On Sat, 17 Jul 2021, Michael Gruner wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The default is to only allow the same format. You need to reimplement</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>the transform_caps virtual method in order to change the format. (note</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>that transform_caps is a basetransform method).</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Great, this works! Thanks very much! I've got a colour-coded image now.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Ideally - if not too much work - I'd also like to get numeric temperature</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>information like on the side bar in the GIF on</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>https://github.com/makerportal/raspi-thermal-cam or maybe in an additional</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>in-frame metadata channel. I found a discussion here</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>https://developer.ridgerun.com/wiki/index.php/GStreamer_and_in-band_metadata</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>but that doesn't seem to have made it to the mainline. I guess the most</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>user-friendly would be adding a side bar like in the former link. It</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>should be possible to extend the width of the image and overlay that kind</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>of information, right?</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Thanks</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Guennadi</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On 17 Jul 2021, at 13:50, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hi Michael,</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On Sat, 17 Jul 2021, Michael Gruner wrote:</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hi Guennadi</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The videoconvert element can already handle this conversion for you:</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>gst-launch-1.0 v4l2src ! videoconvert ! video/x-raw,format=RGB ! …</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Yes, I know about videoconvert, but I need to do some special processing</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>of thermal data. For the algorithms to work I have to access the raw data,</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>which is output by the v4l2 driver in GRAY16_BE format (1-to-1 from the</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>camera), and I want to transform that to a colour gradient similar to well</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>known thermal images, so my plugin cannot just stay within GRAY16_BE and</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>use videoconvert to convert that to RGB - you'd just get a gray image of</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>course.</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>If you, for other reason, need to write your own element, you probably</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>want to use the videofilter base class. It’s a specialization of the</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>basetransform class for video. The important virtual method for you to</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>implement is “transform_caps”, that will allow you to specify the input</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>and output caps respectively.</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The videofilter class is "allowed" to convert between formats? I thought</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>it would be, so I actually tried it. But I was unable to get it to input</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>and output different formats. I was only able to get it to work with the</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>same format. Are you sure that is supposed to work?</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Thanks</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Guennadi</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Michael</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On 17 Jul 2021, at 05:05, Guennadi Liakhovetski via gstreamer-devel <gstreamer-devel@lists.freedesktop.org> wrote:</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hi,</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I'm trying to write a plugin to convert data from a thermal camera. It</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>should take data from the v4l2src source in GRAY16_BE format and convert</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>it to an RGB video output. I'm looking at gst-element-maker but I'm not</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>finding any suitable base class that would take video/x-raw as input and</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>generate the same as output and would convert between format. Do I have to</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>write a plugin from scratch? Or should I use basetransform? Any tutorials</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>for that?</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Thanks</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Guennadi</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>_______________________________________________</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>gstreamer-devel mailing list</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>gstreamer-devel@lists.freedesktop.org</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote></div></blockquote></div></body></html>