VideoHelp Forum
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member
    Join Date
    Oct 2006
    Location
    Poland
    Search Comp PM
    Hi

    I have problem with video card.
    Video card send to my function image in yuy2 how displays on screen (direct3d or directdraw?), how to convers to rgb format ?

    From http://www.fourcc.org/ i get formula to convers yuy2torgb and pictures is very green and violet

    source code:

    b = fixvalue(1.164383 * (y - 16) + 2.017232 * (u - 128))
    g = fixvalue(1.164383 * (y - 16) - 0.391762 * (u - 128) - 0.812968 * (v - 128))
    r = fixvalue(1.164383 * (y - 16) + 1.596027 * (v - 128))

    tmp(l) = r
    tmp(l + 1) = g
    tmp(l + 2) = b
    l += 3

    Best regards
    Tomek

    Quote Quote  
  2. This looks like a YUV image being decoded as if it was RGB. i.e., what ever is decoding the frame thinks it is RGB but it is really YUV.

    Can you give more information?

    Are you sending a frame to the video card or are you getting the frame from the video card?

    Can you post the complete function for converting YUY2 to RGB?
    John Miller
    Quote Quote  
  3. Member
    Join Date
    Oct 2006
    Location
    Poland
    Search Comp PM
    Video Card send image to my function in format YUY2 or YUV 4:2:2 (all have same code 0x44)

    function fixvalues fix to 0-255

    My whole convert function :

    public obrazkamera() as byte

    Function Yuy2toRgb() As Byte()
    Dim y, y1, u, v As Integer
    Dim r, g, b As Byte
    Dim r1, g1, b1 As Byte
    Dim i, j, l As Integer
    Dim tmp() As Byte
    Dim YUYwidth, YUYheight As Integer
    Dim dlugoscYUY As Integer
    Dim punkt As Long
    YUYwidth = 320
    YUYheight = 240

    ReDim tmp(YUYwidth * YUYheight * 3)

    YUYwidth = YUYwidth - 1 'uwaga

    dlugoscYUY = '(YUYwidth) * 2

    l = 0

    If obrazkamera Is Nothing Then
    Yuy2toRgb = tmp
    Exit Function
    End If

    For j = 0 To YUYheight - 1
    For i = 0 To dlugoscYUY - 2 Step 2

    punkt = j * (dlugoscYUY) + i
    If i Mod 4 = 0 Then

    y = CInt(obrazkamera(punkt))
    u = CInt(obrazkamera(punkt + 1))
    v = CInt(obrazkamera(punkt + 3))

    Else

    u = CInt(obrazkamera(punkt - 1))
    v = CInt(obrazkamera(punkt + 1))
    y = CInt(obrazkamera(punkt))
    End If

    r = fixvalue(1.164383 * (y - 16) + 1.596027 * (v - 128))
    g = fixvalue(1.164383 * (y - 16) - 0.391762 * (u - 128) - 0.812968 * (v - 128))
    b = fixvalue(1.164383 * (y - 16) + 2.017232 * (u - 128))

    tmp(l) = r
    tmp(l + 1) = g
    tmp(l + 2) = b
    l += 3

    Next
    Next

    End Function
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!