Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextObjectFilterRender implementation guide #1700

Open
OsamuBlack opened this issue Jan 12, 2025 · 3 comments
Open

TextObjectFilterRender implementation guide #1700

OsamuBlack opened this issue Jan 12, 2025 · 3 comments

Comments

@OsamuBlack
Copy link

OsamuBlack commented Jan 12, 2025

Hi Pedro,

I was setting up text using the TextObjectFilterRender and got most things to work. The issue I am facing is with scaling and positioning.

  • All texts are stretched to the same width, and it also gets stretched
  • Changing the position by one causes it to move by more than 1 px.

Code:

  val text = TextObjectFilterRender()

  text.setText(
      it.text,
      it.textSize,
      Color.WHITE,
      Typeface.BOLD
  )

  text.setPosition(
      it.x,
      it.y
  )

  val isPortrait = height > width;

  if (isPortrait)
      text.setPreviewSize(
          height,
          width,
      )
  else
      text.setPreviewSize(
          width,
          height,
      )

  rtmpCamera.getGlInterface().addFilter(text)

Values:

textWithPosition = {ArrayList@10356}  size = 3
 0 = {
  text = "Live Stream"
  
  textSize = 300.0
  x = 2.0
  y = 2.0
}
 1 = {
  text = "1600"
  
  textSize = 300.0
  x = 2.0
  y = 8.0
}
 2 = {
  text = "1200"
  
  textSize = 300.0
  x = 2.0
  y = 16.0
}

width = 720
height = 1337

Source 2025-01-12 at 14 32 57_44f0be4c

@pedroSG94
Copy link
Owner

Hello,

The scale is working as expected because the image adapt exactly to the size selected. I can add a method to obtain the original resolution. This way you can use it as reference to adapt your scale without distortion.

About the position, the scale and position is working in percent, no in px but you can calculate the percent to move a px.
For example. If you are using resolution 640x480 and you want move 1px in width:
1 * 100 / 640 = 0.15625f

@OsamuBlack
Copy link
Author

ok,

@OsamuBlack
Copy link
Author

Thanks, i will share the updated code once it

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

No branches or pull requests

2 participants