类 TSRPass


  • public class TSRPass
    extends java.lang.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.

    Usage:

    1. 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. Release resources when the TSRPass object is no longer needed by calling the release() method.

    Example:

     // Create a TSRPass object using the constructor.
     TSRPass tsrPass = new TSRPass();
    
     // The code below must be executed in glThread.
     //----------------------GL Thread---------------------//
     // Init TSRPass
     tsrPass.init(inputWidth, inputHeight, srRatio);
     // If the type of inputTexture is TextureOES, you must transform it to Texture2D.
     int outputTextureId = tsrPass.render(inputTextureId);
    
     //----------------------GL Thread---------------------//
    
     // Release resources when the TSRPass object is no longer needed.
     tsrPass.release();
     
    • 嵌套类概要

      嵌套类 
      修饰符和类型 说明
      static class  TSRPass.TSRAlgorithmType
      The TSRAlgorithmType enum value representing the algorithm running mode to be used.
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      void init​(int inputWidth, int inputHeight, float srRatio)
      Init TSRPass object for super-resolution.
      void release()
      Releases the resources.
      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)
      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. This method must be executed after TSRSdk.init(long, TSRSdk.TSRSdkLicenseVerifyResultCallback, TSRLogger), TSRPass.TSRAlgorithmType
        参数:
        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 result accuracy. PROFESSIONAL mode prioritizes result accuracy, even if the running speed is slower.
    • 方法详细资料

      • init

        public void init​(int inputWidth,
                         int inputHeight,
                         float srRatio)
        Init TSRPass object for super-resolution. This method must be called in the GLThread.
        参数:
        inputWidth - The width of the input image
        inputHeight - The height of the input image
        srRatio - The magnification factor for super-resolution, ranging from 1 to 2. When srRatio is less than 1, set its value to 1; when srRatio is greater than 2, set its value to 2.
      • setParameters

        public void setParameters​(float brightness,
                                  float saturation,
                                  float contrast)
        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.
      • render

        public int render​(int textureId)
        Performs the super-resolution rendering operation on the input image. This method must be performed in the GLThread.
        This method applies the super-resolution rendering process to the input image, improving its quality. The processed image is rendered onto a texture within the TSRPass object. And the return is the texture's id.

        NOTE: The type of the texture corresponding to the textureId you pass in must be texture2D.
        参数:
        textureId - The OpenGL textureId of the input image that needs to be processed for super-resolution. The corresponding texture is a texture2D texture.
        返回:
        The textureId of the texture2D after super-resolution rendering, which is stored inside the TSRPass object. 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 performed in the GLThread.

        This method applies the super-resolution rendering process to the input image, improving its quality, and 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 return is the texture's id.

        NOTE: The type of the texture corresponding to the textureId you pass in must be texture2D.

        参数:
        textureId - The OpenGL textureId of the input image that needs to be processed for super-resolution. The corresponding texture is a texture2D texture.
        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 size of the output texture is (inputWidth * srRatio, inputHeight * srRatio).
      • release

        public void release()
        Releases the resources.
        This method should be called when the TSRPass object is no longer needed, to free up the memory and other resources.