Re: Need help in converting YUV to RGB using OV7620



On 13/01/2006 the venerable nuky8181 etched in runes:

> Hi,
>
> I have read a few post about OV7620 and I cant find one that is related to
> my problem. Hope you guys can give me some advise on converting the YUV
> data obtained from OV7620 to RGB format.
>
> I am using the OV7620 in its default mode thus I am only getting 16bit YUV
> data. This is the first time I am using camera chip and from the data
> ***, the following is what I have understood. Pls correct me if I am
> wrong.
>
> YUV data is obtained in the following way
> clk 1 Y0 U0
> clk 2 Y1 V1
> clk 3 Y2 U2 etc
>
> The format is 4:2:2 format thus to get RGB I need to do the following
> Example,
> To get RGB for 1st pixel, Y0 U0 and V1 is used in the computation
> to get RGB for 2nd pixel, Y1 U0 and V1 is used
>
> The formula given in the data *** to get YUV was as followed
> Y=0.59G +0.31R + 0.11B
> U/Cr = 0.713(R-Y)
> V/Cb = 0.594(B-r)
>
> I used matlab to get the conversion from YUV to RGB in the following
> R = Y + 1.4025[U-128]
> G = 0.983*Y + 0.7369[U-128] - 0.3306[V-128]
> B = Y - 1.773[V-128]
>
> The 128 was include to shift U and V from the range 16 - 240 to
> -112 - 112.
>
> What I did was get the YUV data using DSPIC30F6012 and transfer it to
> visual basic and use the RGB formula obtain above to get RGB but I never
> seem to get it. the result is always a green image regardless the colour
> of the image taken.
>
> I have check that there is no data corruption during transfer and is now
> really stuck. I have also tried other forumla found in other website where
> one of which is microsoft msdn. Still, no avil.
>
> I would really appreciate if anyone could help me out here.
>
> Thanks in advance.

Why not set the OV7620 to output RGB data then you don't have to do the conversion.

If you do want to use Y, Cb & Cr, then run a simple test using 100% RGB colour bars as dummy data
that will quickly tell you if your formulae are correct.

R G B <-> Y Cr Cb
White 255 255 255 235 128 128
Yellow 255 255 0 210 146 16
Cyan 0 255 255 170 16 166
Green 0 255 0 145 34 54
Magenta 255 0 255 106 222 202
Red 255 0 0 81 240 90
Blue 0 0 255 41 110 240
Black 0 0 0 16 128 128


--
John B
.


Quantcast