Closed puddly closed 6 years ago
Merged (I hope) Thanks very much for this work!
Can you check the compiled binary: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/pull/590 thanks!
Switching between fixed/variable and small/big fonts doesn't work properly because of an issue with the configuration object I missed. It's been fixed now in my branch (https://github.com/puddly/Main/commit/ead5aa04eba3d7fdf611e225416e295c18b392b6).
I guess there is also another problem: it happens that font is null when calling osd_draw_timestamp it is at process startup (setting from web: position is 400, fixed width=no and size is small I used the code in your branch (puddly@ead5aa0).
Sorry, I did not think to test starting the server with different options. Fixed as of https://github.com/puddly/Main/commit/7e67cfd2f69d582b73ef21ceca39c990fa1bb5cc
The small sans-serif font is still not rendered very well, so I do agree that FreeType will be a massive improvement over the current method of rendering the OSD text.
The branch you are referring is not the correction :-)
It was fixed in the commit prior to that one (https://github.com/puddly/Main/commit/026b383595961bc67221e520b8eab262faedd6e1), I just accidentally pushed a change intended for a different branch earlier.
Check this one: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/pull/592
I finished adding support for FreeType so it might just be easier to merge that branch instead, once everything is properly tested this time.
The only minor issue I'm having at the moment is getting everything to compile nicely with the build scripts in the repository. I was able to build and link FreeType2 but only after adding its compilation steps into the compile-libraries.sh
script and making some additions to the v4l2rtspserver-master/CMakeLists.txt
, but I'm not too familiar with CMake.
Cool !! Good news can you create a PR it will b easier to merge ... No worries about the libs, it is the same with the others
I succeeded merging it ! It works like a charm ... I am just trying to make the font name and the font size configurable through setconf. For me it is always taking too much CPU. Will adjust the sleep The goodnews is that the memory is the same
There isn't a whole lot you can do with the sleep call because it runs exactly once per second at the same time (it's set to run at 100ms
past the second). Any changes will make the OSD timestamps skip seconds or appear to count unevenly.
I'm guessing the main inefficiency comes from loading and rendering glyphs from the font every time the OSD is displayed, but profiling really should help determine the root cause. Some options:
Agree with you assessments. I guess most of the people (like me) doesn't care about the seconds. I see my camera on my phone through 3G or 4G network ... I can make it configurable if you want
Can you check this: https://github.com/Dafang-Hacks/Main/pull/21
setconf -k g -v 0
to get your wanted precisionThose changes look good to me.
I realized that I missed a zero in the nanosleep
delay, which caused the main update_thread
to run every 100ms instead of every second. This was the root cause of the CPU usage issue you saw and has been fixed as of https://github.com/puddly/Main/commit/06ba5cff44e83bc56b2b2fe4d5f6c873be07618f. I don't think the refresh time setting is really necessary now unless there's a real use for it besides performance reasons.
Cairo speeds up things a little bit, even when used inefficiently. Here's my quick attempt at using it to render only the text.
Yeah, working better ... I did a quick test this morning, will push it this evening What is the gain of Cairo ? Does it worth it?
I've never used FreeType or Cairo for anything besides this so I can't speak authoritatively, but I found Cairo to be much easier to work with than using FreeType directly. It also uses a pixel-manipulation library that contains optimizations for the MIPS instruction set and has font caching, which might be useful.
That being said, it probably makes no difference if the only thing being rendered is a line of text and maybe some rectangles in the future. Rendering everything takes about 0.02 seconds for me, which includes time spent in the magic IMP
library.
Agree, then let's stick on Freetype ...
The current OSD font is hard-coded to one of two sizes of a proportional font. I've added a proper fixed-width font and moved the font definition preprocessor macros into wrapper classes for each font.