Results 1 to 3 of 3

Thread: UYVY -> RGB Conversion

  1. #1
    Registered User
    Join Date
    Oct 2017
    Location
    NY
    Posts
    24

    UYVY -> RGB Conversion

    Hello,

    My program receiving NDI video in UYVY pixel format and then use OPENGL shader to draw it on the screen. The problem is that I can't find correct way to convert UYVY to RGB.
    For HD content I use following code:
    ===========
    yuv.x = texture2D(u_texture, v_texCoord).g-0.0625;
    yuv.yz = texture2D(u_texture_uv, v_texCoord).rb-0.5;
    rgb = mat3( 1.1643, 1.1643, 1.1643,
    0, -0.213, 2.115,
    1.793, -0.534, 0) * yuv;
    };
    rgb = clamp(rgb,0.0, 1.0);
    ===========
    It works but picture still have little difference in details with RGB picture that directly provided by NDI SDK

    What the correct way to do UYVY -> RGB Conversion?

    Best Regards,
    Dmitry

  2. #2
    Registered User
    Join Date
    Nov 2017
    Location
    Delhi
    Posts
    3

  3. #3
    Registered User
    Join Date
    Oct 2017
    Location
    NY
    Posts
    24
    Hi Arzoo,

    Thanks for you links.
    Also yesterday Andrew have provided me a shader that used by Studio Monitor
    ==========================
    varying vec4 tx_coord;

    uniform sampler2D video_Y, video_CbCr;

    mat3 ycbcr_to_rgb_mat = mat3(1.16414, -0.0011, 1.7923, 1.16390, -0.2131, -0.5342, 1.16660, 2.1131, -0.0001);
    vec3 ycbcr_to_rgb_vec = vec3(-0.9726, 0.3018, -1.1342);

    void main()
    {
    vec3 col_y_cbcr = vec3(texture2D(video_Y, tx_coord.xy).r, texture2D(video_CbCr, tx_coord.xy).rg);
    vec3 col_rgb = vec3( dot( ycbcr_to_rgb_mat[0], col_y_cbcr ), dot( ycbcr_to_rgb_mat[1], col_y_cbcr ), dot( ycbcr_to_rgb_mat[2], col_y_cbcr ) ) + ycbcr_to_rgb_vec;
    gl_FragData[0] = vec4( col_rgb, 1.0 );
    }
    ==========================

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •