This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8148: GPU compositing rotation stretching

Hello,

I  am currently using the GPU composition module to rotate an input video frame captured from my camera and then rotate dynamically. Everythink works fines execpt that I would like to rotate the video frame without stretching the image on the whole screen.

Here is the displayed frame I have :

And this what I should have:

 ]

Is there a way to avoid this stretching effect ?

Thank you very much,

Dylan

  • Anyone ?

    I will really appreciate some help here


    Thanks

  • I finally found the answer. It was pretty easy. In the GPU compositing module, the pixels are represented by matrices (4x4). The Z axis rotation is done by calculating the cos and sin of the rotate angle and filling the matrice with these values.

    The values used are texture coordinates, that means that it is from -1.0 to 1.0. That means that just by dividing by 2 the sinus angle value, we will have the expected result.

    The new rotation matrice is this:

    void matrixRotateZ(float degrees, mat4 matrix)
     {
         float radians = degreesToRadians(degrees);
          matrixIdentity(matrix);
          // Rotate Z formula. 
    	matrix[0] = cosf(radians);
        matrix[1] = sinf(radians)/2;
        matrix[4] = -matrix[1];
        matrix[5] = matrix[0]; 
    }

    Thank you anyway !

    Dylan