This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Best approach to writing text into YUV?



I'd like to write text into the captured YUV data before compressing into H.264 on the DM368.  I could just do it the hard way and figure it out for myself.  But I was hoping that there may already be an established method or at least some code that available.

Any ideas?

Thanks,

John A

  • Please have a look at the DMAI directory inside DVSDK. There are some API, and there should be a "simple widget" folder as well. It should support what you are doing, however, it is not very simple to integrate

  • Hi John, I am busy struggling with simple widget in order to add text to my video but decided to come see on the forum if there are simpler ways as I am not using dmai and don't have all the structures they are using so integration is painful.  Did you find another way to do it or is the freetype2 way the one to go?  My application currently takes PAL frames coming in and adds bargraph data on the left edge and also puts a crosshair on or off.  I couldn't get OSD to work so I am putting everything straight into my display buffer and will also bang the "text" in there as well.

    Thanks, Jinh T.

  • Jinh, I've been so busy with other development issues I haven't had a chance to resolve this problem.

    John A

  • for my software expertise this is another hard one but it looks viable with the freetype way from dvsdk demo's.  Will let you know after some serious butchering (hopefully) today.... hacking is an understatement for this.

    Cheers, Jinh T.

  • I got the text displaying using the simplewidget code and freetype libraries.  A question I have now is if there is an optimum size of font or type of font that will make the processing power used the most optimised or does it all depends on how much text needs to be rendered?  Any guidelines on fonts and its usage would be appreciated.

    Thanks, Jinh T.

  • Hi Jinh,

    That's great to hear.  So you are writing into a YUV buffer?  Is this the buffer that gets encoded?  I need to put text into the captured YUV buffer before it goes to the encoder.  I'm using an H.264 encoder and the buffer is in 420 SEMIP format, which is a bit more goofy than regular UYVY.

    Is the text a single color with transparent background?  Can you alpha blend the text?  If you don't have a shaded character or alpha blended background then the text can be hard to see depending on the video behind it.

    John A

  • Hi John, I am writing this directly into my uyvy display buffer just before displaying i.e after vsunc I copy the capture buffer to display buffer and add my left edge bargraph stuff and then put my crosshair on and then put the text in and then it gets displayed.  In the normal flow of things this could go to encoding but I am working with non-encoded video.  From the function Text_show() I used the colorspace option for RGB565 because my uyvy is 12 bits which should also work for 420semip I guess.  All these fourcc formats going into v4l2 still confuses me bigtime.

    I couldn't get the OSD going but wanted to use it and then would have been able to do all the blending and stuff but it is a bit of a nice-to-have on my app so I left it and just bangs everything into the normal display.  The text is quite visible on my black-and white setup but a nice block allocated to OSB would have been nice to frame the block of text because the font gets rendered into a small window that fits the glyph.  Maybe one day the OSD will also work and that would be first prize.

    My problem now is that putting the text on take a whack of processing and I am trying to figure out how to make something like a system font with one size so that the library just gets displayed without sizing and rendering etc...if I understand it all correctly but any inputs would be welcome on how to make processor usage a minimum as I am trying to do realtime in a non-hard-realtime environment and do get by just putting my edge data in but adding the crosshair and text makes me loose frames but in operational mode I am fine with the processor running at 25% usage.

    Cheers, Jinh T.