Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Why the rendering effect of samples/SampleOpenGL.py is flipped vertically. #550

Open
TurtleZhong opened this issue Nov 14, 2023 · 1 comment

Comments

@TurtleZhong
Copy link

Describe the bug
In samples/SampleOpenGL.py, the rendering effect of OpenGL is flipped vertically. here is the origin video in tests/test.mp4
image

and below is the render results of OpenGL
image

python3 SampleOpenGL.py -g 0 -e /PATH/VideoProcessingFramework/tests/test.mp4

To Reproduce
Steps to reproduce the behavior:

  1. Before I use this command line, I need fix some bugs in SampleOpenGL.py, Line 346 and Line 347 need to be exchanged.
  2. Go to the samples folder and run
python3 SampleOpenGL.py -g 0 -e /PATH/VideoProcessingFramework/tests/test.mp4
  1. Then we can get the above result.
  2. See error->the rendering result is flipped vertically.

Screenshots

vpf-opengl-2023-11-14_10.26.42.mp4

Desktop (please complete the following information):

  • OS: [Linux, ubuntu 20.04]
  • Nvidia driver version[535.129.03]
  • CUDA Version [11.4]
  • Python Version [3.8]
  • Video Codec SDK Version [latest]
@wld22145
Copy link

Hi, I faced the same problem and here is my solution:

Add one line of code in the vertex shader of the compile_shader() function to vertically flip the uv coordinates:

vertex_shader_source = """
        #version 450 core
        out vec2 uv;
        void main( void)
        {
            // Declare a hard-coded array of positions
            const vec2 vertices[4] = vec2[4](vec2(-0.5,  0.5),
                                                 vec2( 0.5,  0.5),
                                                 vec2( 0.5, -0.5),
                                                 vec2(-0.5, -0.5));
            // Index into our array using gl_VertexID
            uv=vertices[gl_VertexID]+vec2(0.5,0.5);
            uv.y = 1.0 - uv.y; // Flip the texture vertically
            gl_Position = vec4(2*vertices[gl_VertexID],1.0,1.0);
            }
        """

Hopefully, this will also work for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants