Dynamic text on video frame

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic text on video frame

eyalhir74
Hi,
  I've looked a lot for a C++ example of how to do this, but couldn't find
any.
  I have a v4l2src element and would like to display the frame ID on each
frame coming out of the camera.
  I later on save the frames using a tee to display and record.
  How can I do this?

thanks
Eyal



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

Nicolas Dufresne-5
Le mercredi 15 juillet 2020 à 06:33 -0500, eyalhir74 a écrit :
> Hi,
>   I've looked a lot for a C++ example of how to do this, but couldn't find
> any.
>   I have a v4l2src element and would like to display the frame ID on each
> frame coming out of the camera.
>   I later on save the frames using a tee to display and record.
>   How can I do this?

You can build an app with the following pipeline:

  v4l2src ! tee name=t
     t. ! queue ! textoverlay name=overlay ! glimagesink
     t. ! queue ! ....

Then in your app, you'd add a pad probe before text overlay, and update
the "text" property on textoverlay for each frames that pass by. I will
let you define what a "frame ID" is as it is not a GStreamer concept.
You can embed glimagesink into your application using GstVideoOverlay
interface. The overlayed text will be composed in GL with glimagesink,
so this is suitable for high resolution too.


>
> thanks
> Eyal
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

eyalhir74
Hi,
  I'm kinda new so would appreciate some further detail information.
  I did not find any reference (c++ code) as to how to do this - the
documentation says:
  "This can be either static text or text from buffers received on the text
sink pad, e.g. as produced by the subparse element. If the text sink pad is
not linked, the text set via the "text" property will be rendered. If the
text sink pad is linked, text will be rendered as it is received on that
pad, honouring and matching the buffer timestamps of both input streams."
 
  what are those buffers?

  I did something like this, but I get the same "frame id" for the roughly
two consecutive frames captured by the camera.
  As if the callback is slower than the rest of the pipe??


        m_Lrv_file_src = Gst::ElementFactory::create_element("v4l2src",
"lrv-v4l2src");

        GstPad *pad = gst_element_get_static_pad
(m_Lrv_file_src.get()->gobj(), "src");
        gst_pad_add_probe (pad,GST_PAD_PROBE_TYPE_BUFFER,
(GstPadProbeCallback) cb_have_data, this, NULL);
        gst_object_unref (pad);

    static GstPadProbeReturn
    cb_have_data (GstPad          */*pad*/,
                  GstPadProbeInfo */*info*/,
                  gpointer         user_data)
    {
        static std::atomic<int> kkk = 0;
        InferModule *data = (InferModule *)user_data;
        std::string frame_id = std::to_string(kkk);
        data->m_Debug_overlay->set_property("text", frame_id);
        kkk++;
        return GST_PAD_PROBE_OK;
    }


Any further assistance is more than welcomed.

Thanks
Eyal



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

eyalhir74
Hi,  
  Any assistance would be greatly appreciated

thanks
Eyal



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

Nicolas Dufresne-5
Le jeudi 16 juillet 2020 à 08:29 -0500, eyalhir74 a écrit :
> Hi,  
>   Any assistance would be greatly appreciated

Some resource for you:

https://gstreamer.freedesktop.org/documentation/application-development/basics/helloworld.html?gi-language=c
https://gstreamer.freedesktop.org/documentation/application-development/advanced/pipeline-manipulation.html?gi-language=c

You may also want to go through the tutorials and to understand better.

https://gstreamer.freedesktop.org/documentation/tutorials/index.html?gi-language=c

It's all C, but C++ code can use C with minor cast operations here and there.

>
> thanks
> Eyal
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

eyalhir74
Hi,
  Obviously I read and didn't find any reference/code sample to explain
why/how to make the code, correctly, display the frame ID/number on the
frame video.
  Any concrete explanation how to achieve this, would be greatly
appreciated.

thanks
Eyal



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

eyalhir74
Hi,
  I've also used the identity and textoverlay components to do this, still
there are video frames with the same id..


    void identityHandoff(const Glib::RefPtr<Gst::Buffer> &/*arg0*/)
    {
        std::lock_guard<std::mutex> lock(m_frame_id_mutex);
        static int frame_id = 0;
        m_Debug_overlay->set_property("text", frame_id);
        frame_id++;
    }

    Glib::RefPtr<Gst::Identity> debug_identity =
Glib::RefPtr<Gst::Identity>::cast_dynamic(m_Debug_identity);
    debug_identity->signal_handoff().connect(sigc::mem_fun(this,
&identityHandoff));


thanks
Eyal



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic text on video frame

mhassan
In reply to this post by eyalhir74
I am sort in the same boat as you are i.e. new to gstreamer and looking to
build something similar although I'm using the Rust bindings. I would
greatly appreciate a bit more information or explanation as to how one would
achieve overlaying dynamically changing text on a video.

I actually want to correlate GPS location data from a JSON file which also
has timestamps for the changing lat-long coordinates and want to display
them in the corner of the video through the length of the video.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel