Skip to content

Adjust font size dinamically#14

Open
hunminkim98 wants to merge 12 commits intodavidpagnon:mainfrom
hunminkim98:dynamic_font
Open

Adjust font size dinamically#14
hunminkim98 wants to merge 12 commits intodavidpagnon:mainfrom
hunminkim98:dynamic_font

Conversation

@hunminkim98
Copy link
Copy Markdown
Contributor

@hunminkim98 hunminkim98 commented Sep 3, 2024

Hello, Dr. David.
Thanks for the great work you always do.

After doing some testing, I realized that it would be nice to be able to adjust the font size dynamically, so I created this pull request to make it relatively simple. When you get a chance, I'd appreciate it if you could look at it.

Several test result:
3840 x 2160: font size = 1
3840 x 2160

2704 x 1520: font size = 0.7
2704 x 1520

1376 x 910: font size = 3.2
1376 x 910

@davidpagnon
Copy link
Copy Markdown
Owner

Thanks, it's a good idea indeed! I'll check that next week :)

@davidpagnon
Copy link
Copy Markdown
Owner

This is cool!
While you are at it and if you have time, could you also adjust as a function of the resolution

  • the thickness of bboxes and of skeletons, and
  • the size of the keypoints?
    Thanks again

@davidpagnon
Copy link
Copy Markdown
Owner

Little remark: instead of
if fontSize == 'auto' or fontSize == 'Auto':
you can do if fontSize.lower() == 'auto' so that it is case insensitive

Can you also test if it looks as good with videos taken in portrait mode?

@hunminkim98
Copy link
Copy Markdown
Contributor Author

hunminkim98 commented Sep 5, 2024

Hello, I've updated the thickness.
Now, thickness will adjust based on font size. And the size of the keypoints is still set to thickness+4 (I tested several values, and I believe +4 works best).
The thickness should be an integer, so it can't be a float (since a float allows decimal points, which is less flexible than I expected).

I also tested it in a portrait video, and I believe it's good enough!

Detail results

  • 3840 x 2160 : font size = 1, thickness = 3, size of keypts = 7(If you think a thickness of 3 is too thick, I’ll set the maximum thickness to 2).
    4K_Sports2D_000000

  • 2704 x 1520: font size = 0.7, thickness = 2, size of keypts = 6
    1111_Sports2D_000506

  • 1376 x 910: font size = 3.2, thickness = 1, size of keypts = 5
    2222_Sports2D_000053

  • 1080 x 1920 (portrait): font size = 3.5, thickness = 1, size of keypts = 5
    p_Sports2D_000023

@davidpagnon
Copy link
Copy Markdown
Owner

Thank you! A few questions:

  • I feel like the font size should be set as a function of the maximum dimension (width or height), rather than as a function of their multiplication, because it is quite hard to read the values of the last image on the screen of a small laptop
  • In general, image quality is okay, but we lose a lot of information in the videos, which makes everything blurrier. Lines are often not very well rendered, so I think it is better to have them a bit too thick than the opposite
  • I do not see the text outline in the first image but I don't understand why since you did not change the "tickness+1" variables. Do you have any idea why it is like this?
  • It would be ideal if you managed to have a few parameters in the functions as possible (getting rid of min and max if this is possible, and potentially grouping base and scale under the same parameter)
  • Since it is used for writing the angles and drawing the lines, and that these functions are in the main process.py file, I would put these functions there rather than in the common.py file

@hunminkim98
Copy link
Copy Markdown
Contributor Author

Hello, I appreciate your valuable feedback!

Here is the answer:

  • Now, the font size will adjust based on the maximum dimension, but I'm not sure if it fits your intention.
  • Great idea! Now, the line thickness will be at least 2, while the text remains the same as before (for readability).
  • You're right. It should be adjusted to another value. I thought +1 was enough, but actually, it wasn't. Sorry for missing that. So, I set the value to thickness * 3. I believe this will give us better readability.
  • I removed a few parameters, but the features remain the same as before. I hope it fits your intention.
  • I moved the functions to process.py from common.py.

Detail results

  • 3840 x 2160 : font size = 0.78, thickness = 3
    4K_Sports2D_000000

  • 2704 x 1520: font size = 0.55, thickness = 2
    1111_Sports2D_000463

  • 1376 x 910: font size = 0.28, thickness = 1 for texts, 2 for lines
    2222_Sports2D_000037

  • 1080 x 1920 (portrait): font size = 0.39, thickness = 1 for texts, 2 for lines
    p_Sports2D_000097

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants