类 TSRPass

java.lang.Object
com.tencent.mps.tie.api.TSRPass

public class TSRPass extends Object
TSRPass is a class responsible for performing super-resolution rendering on input images. The class creates a TSRPass object and provides methods for initialization, rendering, and releasing resources.

Note:

  • All methods of TSRPass must be called within the same GLThread.
  • The render method should not be called before the init method, and it should not be called after the deInit method.

Usage:

  1. (In glThread) Create a TSRPass object using the constructor.
  2. (In glThread) Initialize the TSRPass object by calling the init(int, int, float) method.
  3. (In glThread) Perform super-resolution rendering on an input opengl texture by calling the render(int) method.
  4. (In glThread) Release resources when the TSRPass object is no longer needed by calling the deInit() method.

STANDARD SDK Example:

 // The code below must be executed in the same glThread.
 //----------------------GL Thread---------------------//

 // Create a TSRPass object using the constructor.
 TSRPass tsrPass = new TSRPass(TSRPass.TSRAlgorithmType.STANDARD);

 // Initialize TSRPass and set the input image width, height and srRatio.
 tsrPass.init(inputWidth, inputHeight, srRatio);

 // If the type of inputTexture is TextureOES, you must transform it to Texture2D.
 // Conversion code can be written according to actual requirements.

 // Perform super resolution rendering on the input OpenGL texture and get the enhanced texture ID.
 int outputTextureId = tsrPass.render(inputTextureId);

 // Release resources when the TSRPass object is no longer needed.
 tsrPass.deInit();

 //----------------------GL Thread---------------------//

 

PROFESSIONAL SDK Example:

 // The code below must be executed in the same glThread.
 //----------------------GL Thread---------------------//

 // Create a TSRPass object using the constructor.
 TSRPass tsrPass = new TSRPass(TSRPass.TSRAlgorithmType.PROFESSIONAL_HIGH_QUALITY);
 // TSRPass tsrPass = new TSRPass(TSRPass.TSRAlgorithmType.PROFESSIONAL_FAST);

 // Initialize TSRPass and set the input image width, height and srRatio.
 tsrPass.init(inputWidth, inputHeight, srRatio);

 // If the type of inputTexture is TextureOES, you must transform it to Texture2D.
 // Conversion code can be written according to actual requirements.

 // Perform super resolution rendering on the input OpenGL texture and get the enhanced texture ID.
 int outputTextureId = tsrPass.render(inputTextureId);

 // Release resources when the TSRPass object is no longer needed.
 tsrPass.deInit();

 //----------------------GL Thread---------------------//
 
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static enum 
    The TSRAlgorithmType enum represents the algorithm running mode to be used for super-resolution rendering in the TSRPass class.
  • 构造器概要

    构造器
    构造器
    说明
    Creates a TSRPass object for super-resolution rendering.
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Releases the resources associated with the TSRPass object.
    boolean
    init(int inputWidth, int inputHeight, float srRatio)
    Initializes the TSRPass object for super-resolution rendering.
    int
    render(int textureId)
    Performs the super-resolution rendering operation on the input image.
    int
    render(int textureId, float[] transformMatrix)
    Performs the super-resolution rendering operation on the input image with a specified transform matrix.
    void
    setParameters(float brightness, float saturation, float contrast, float sharpness)
    Set the parameters of the rendering operator.

    从类继承的方法 java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • TSRPass

      public TSRPass(TSRPass.TSRAlgorithmType algorithmType)
      Creates a TSRPass object for super-resolution rendering.

      This constructor should be called after initializing the TSRSdk using TSRSdk.init(long, int, TSRSdk.TSRSdkLicenseVerifyResultCallback, TSRLogger). The created TSRPass object will use the specified TSRPass.TSRAlgorithmType for its rendering operations.

      参数:
      algorithmType - The TSRAlgorithmType enum value representing the algorithm running mode to be used. It can be either STANDARD (fast mode) or PROFESSIONAL (quality mode). STANDARD mode prioritizes better performance in terms of speed, possibly sacrificing some image quality. PROFESSIONAL mode prioritizes better image quality, even if the running speed is slower.
      另请参阅:
  • 方法详细资料

    • init

      public boolean init(int inputWidth, int inputHeight, float srRatio)
      Initializes the TSRPass object for super-resolution rendering. This method must be called within the GLThread. The input parameters specify the dimensions of the input image to be processed and the magnification factor for super-resolution.
      参数:
      inputWidth - The width of the input image to be processed. This value should be greater than zero.
      inputHeight - The height of the input image to be processed. This value should be greater than zero.
      srRatio - The magnification factor for super-resolution. This value should be greater than zero and determines the scaling applied to the input image during the rendering process.
      返回:
      A boolean value indicating the result of the initialization.
      • Returns true if the initialization is successful.
      • Returns false if the initialization fails.
    • setParameters

      public void setParameters(float brightness, float saturation, float contrast, float sharpness)
      Set the parameters of the rendering operator. It needs to take effect after init(int, int, float) is called.
      参数:
      brightness - The brightness level to apply. Valid values are between 0 and 100, with a default value of 50.
      saturation - The saturation level to apply. Valid values are between 0 and 100, with a default value of 50.
      contrast - The contrast level to apply. Valid values are between 0 and 100, with a default value of 50.
      sharpness - The sharpness factor to apply Valid values are between 0 and 100, with a default value of 0.
    • render

      public int render(int textureId)
      Performs the super-resolution rendering operation on the input image. This method must be called within the GLThread.

      This method applies the super-resolution rendering process to the input image, improving its quality by increasing its resolution. The processed image is rendered onto a texture within the TSRPass object, and the texture's ID is returned.

      NOTE:

      • The type of the texture corresponding to the textureId you pass in must be texture2D.
      • The format of the input OpenGL texture must be GL_RGBA.
      • The format of the output textureId is also GL_RGBA.

      参数:
      textureId - The OpenGL textureId of the input image that needs to be processed for super-resolution. The corresponding texture is a texture2D texture with GL_RGBA format.
      返回:
      The textureId of the texture2D after super-resolution rendering, which is stored inside the TSRPass object. The format of the output texture is GL_RGBA. The size of the output texture is (inputWidth * srRatio, inputHeight * srRatio).
    • render

      public int render(int textureId, float[] transformMatrix)
      Performs the super-resolution rendering operation on the input image with a specified transform matrix. This method must be called within the GLThread.

      This method applies the super-resolution rendering process to the input image, improving its quality by increasing its resolution. Additionally, it uses the given transform matrix to manipulate the image during the rendering process. The processed image is rendered onto a texture within the TSRPass object, and the texture's ID is returned.

      NOTE:

      • The type of the texture corresponding to the textureId you pass in must be texture2D.
      • The format of the input OpenGL texture must be GL_RGBA.
      • The format of the output textureId is also GL_RGBA.

      参数:
      textureId - The OpenGL textureId of the input image that needs to be processed for super-resolution. The corresponding texture is a texture2D texture with GL_RGBA format.
      transformMatrix - A float array representing the transform matrix to be applied to the input image during the rendering process. The matrix should be in column-major order and of size 16.
      返回:
      The textureId of the texture2D after super-resolution rendering and applying the transform matrix, which is stored inside the TSRPass object. The format of the output texture is GL_RGBA. The size of the output texture is (inputWidth * srRatio, inputHeight * srRatio).
    • deInit

      public void deInit()
      Releases the resources associated with the TSRPass object.

      This method should be called when the TSRPass object is no longer needed, to free up memory and other resources. After calling this method, the TSRPass object should not be used for any further operations.