Forums

OV7620 RGB demosaicing problem

Started by ksanthos October 5, 2007
Hello,

I'm working on an imaging system which uses C3188A digital cmos
camera(contains OV7620 image sensor). It is controlled by a PIC18F452 and
each frame I want to view is stored in a FIFO buffer, AL422B. I can store
a frame and transfer it to my PC by RS232. However I have a problem with
the images, they look gray scale although they should be RGB. 
I have configured OV7620 to transmit QVGA images in progressive mode. I
haven't changed the data mode, it's repetitive because one-line output
format is not supported in qvga mode. The camera is configured to output
raw data also. 
Anyway, when I display the bayer pattern in bmp format, I see that color
sensors do not seem to work properly. I display each pixel as below:
The bayer pattern form is:
B G B G 
G R G R 
bmp file form is:
(0, 0, B), (0, G, 0), (0, 0, B), (0, G, 0)
(0, G, 0), (R, 0, 0), (0, G, 0), (R, 0, 0)
This is just for test purposes. I want to see red things red, blue things
blue and green things green however the sensor doesn't seem to sense them
in that way, they all look the same color which is greenish. I have also
converted bayer pattern into RGB and saw that the image is completely gray
scale although the sensor is configured for raw data output(it looks like
that each components digital value is so close to each other that when 3
components are combined it gives a gray scale pixel). Because the image is
QVGA and it is outputted in repetitive format 2 bytes are sent for each
pixel, am I right? So, I should be receiving 153600 pixels(320 x 240 x 2)
and this is exactly what I count during the transfer. So there shouldn't
be any pixel missing issue. Moreover the camera is connected to the FIFO
memory directly so they synchronize each other by hardware therefore there
shouldn't be any problems caused by software. Other than that I couldn't
find any way to resolve that issue, could anybody help me in that
problem??

Thanks!!

Taskin Baltaci



On Oct 5, 6:52 am, "ksanthos" <taskin.balt...@gmail.com> wrote:
> Hello, > > I'm working on an imaging system which uses C3188A digital cmos > camera(contains OV7620 image sensor). It is controlled by a PIC18F452 and > each frame I want to view is stored in a FIFO buffer, AL422B. I can store > a frame and transfer it to my PC by RS232. However I have a problem with > the images, they look gray scale although they should be RGB. > I have configured OV7620 to transmit QVGA images in progressive mode. I > haven't changed the data mode, it's repetitive because one-line output > format is not supported in qvga mode. The camera is configured to output > raw data also.
<snip> Doesn't the OV7620 output pixels in the YUV colorspace by default? Are you commanding the sensor to switch to RGB mode (by sending an I2C cmd to change an internal register...I don't recall which one off the top of my head, but its clear in the datasheet)? Also, are you using both the Y pixel bus and the UV pixel bus, or just the Y pixel bus? Regards, John O www.jrobot.net
Hello,

first of all thanks for the response! I'm using 8 bit so I'm tristating
the UV bus. And I also set the color space to RGB, I have used the below
I2C commands to configure the chip:

I2CWrite(0x11, 0b00000000);	//slow down pclk (0x00 + 1) times(default
value)
DelayMs(50);
I2CWrite(0x12, 0b00101100);	//output raw data, enable AWB
DelayMs(50);
I2CWrite(0x13, 0b00100001);	//8 bit data format, enable auto adjust mode
DelayMs(50);
I2CWrite(0x14, 0b00100100);	//ucResCtrlSet detayi main()'in yukarisinda	
DelayMs(50);
I2CWrite(0x28, 0b00100000); 	//Progressive scan mode(default is
interlaced), repetetive mode! 
DelayMs(50);
But I'm confused in a point. If I tristate the UV bus, shouldn't it stop
outputting any signal? I mean, shouldn't it be low all the time? Because
when I check it by scope I see some irregular signals on the pin.


>On Oct 5, 6:52 am, "ksanthos" <taskin.balt...@gmail.com> wrote: >> Hello, >> >> I'm working on an imaging system which uses C3188A digital cmos >> camera(contains OV7620 image sensor). It is controlled by a PIC18F452
and
>> each frame I want to view is stored in a FIFO buffer, AL422B. I can
store
>> a frame and transfer it to my PC by RS232. However I have a problem
with
>> the images, they look gray scale although they should be RGB. >> I have configured OV7620 to transmit QVGA images in progressive mode.
I
>> haven't changed the data mode, it's repetitive because one-line output >> format is not supported in qvga mode. The camera is configured to
output
>> raw data also. ><snip> >Doesn't the OV7620 output pixels in the YUV colorspace by default? >Are you commanding the sensor to switch to RGB mode (by sending an I2C >cmd to change an internal register...I don't recall which one off the >top of my head, but its clear in the datasheet)? Also, are you using >both the Y pixel bus and the UV pixel bus, or just the Y pixel bus? > >Regards, >John O >www.jrobot.net > > >
On Oct 5, 7:52 pm, "ksanthos" <taskin.balt...@gmail.com> wrote:
> Hello, > > I'm working on an imaging system which uses C3188A digital cmos > camera(contains OV7620 image sensor). It is controlled by a PIC18F452 and > each frame I want to view is stored in a FIFO buffer, AL422B. I can store > a frame and transfer it to my PC by RS232. However I have a problem with > the images, they look gray scale although they should be RGB. > I have configured OV7620 to transmit QVGA images in progressive mode. I > haven't changed the data mode, it's repetitive because one-line output > format is not supported in qvga mode. The camera is configured to output > raw data also. > Anyway, when I display the bayer pattern in bmp format, I see that color > sensors do not seem to work properly. I display each pixel as below: > The bayer pattern form is: > B G B G > G R G R > bmp file form is: > (0, 0, B), (0, G, 0), (0, 0, B), (0, G, 0) > (0, G, 0), (R, 0, 0), (0, G, 0), (R, 0, 0) > This is just for test purposes. I want to see red things red, blue things > blue and green things green however the sensor doesn't seem to sense them > in that way, they all look the same color which is greenish. I have also > converted bayer pattern into RGB and saw that the image is completely gray > scale although the sensor is configured for raw data output(it looks like > that each components digital value is so close to each other that when 3 > components are combined it gives a gray scale pixel). Because the image is > QVGA and it is outputted in repetitive format 2 bytes are sent for each > pixel, am I right? So, I should be receiving 153600 pixels(320 x 240 x 2) > and this is exactly what I count during the transfer. So there shouldn't > be any pixel missing issue. Moreover the camera is connected to the FIFO > memory directly so they synchronize each other by hardware therefore there > shouldn't be any problems caused by software. Other than that I couldn't > find any way to resolve that issue, could anybody help me in that > problem?? > > Thanks!! > > Taskin Baltaci
Seems inappropriate register setting to me, have you signed NDA with OV? If not then i don't think you would be able to get very details. Just a wild guess, ali
On Friday, in article
     <_pSdnb-v99X2qJvanZ2dnUVZ_jCdnZ2d@giganews.com>
     taskin.baltaci@gmail.com "ksanthos" wrote:
>Hello, > >first of all thanks for the response! I'm using 8 bit so I'm tristating >the UV bus. And I also set the color space to RGB, I have used the below
Hmm this module has OV7620 and a FIFO chip. Hve you told the FIFO that it is only getting 8 bit data mux stream? I suspect half of the problem is you are only adjusting half of the unit and the other half expects 16 bit data still. That is if the serialiser can work with 8 bit mux data on faster clock.
>I2C commands to configure the chip: > >I2CWrite(0x11, 0b00000000); //slow down pclk (0x00 + 1) times(default >value) >DelayMs(50); >I2CWrite(0x12, 0b00101100); //output raw data, enable AWB
Set AGC and AWB on Raw data on output 16/8 bit mode (bit 4) is at 16 bit setting.
>DelayMs(50); >I2CWrite(0x13, 0b00100001); //8 bit data format, enable auto adjust mode
8 bit mode and auto-adjust mode Data format CCIR601 (16bit)
>DelayMs(50); >I2CWrite(0x14, 0b00100100); //ucResCtrlSet detayi main()'in yukarisinda
AWB low threshold QVGA (320 x 480) HREF positive RGB Gamma on No register 15 to match the FIFO to which phase of pixel clock clocks data byte. At least read register 15 and find out what it is set to! HINT in 8 bit mode the clock is twice as fast! You may be clocking the data into the FIFO on the WRONG EDGE. NO regsister 27 to ensure RGB matrix is ON, otherwise your data is YUV multiplexed.
>DelayMs(50); >I2CWrite(0x28, 0b00100000); //Progressive scan mode(default is >interlaced), repetetive mode!
Dual line repetitive mode as well.
>DelayMs(50);
>But I'm confused in a point. If I tristate the UV bus, shouldn't it stop >outputting any signal? I mean, shouldn't it be low all the time? Because >when I check it by scope I see some irregular signals on the pin.
I do not beleive you have fully set the device up and may also have some stray pickup or signal being injected from the serialiser which is expecting 16bit data. See more comments below.
> >>On Oct 5, 6:52 am, "ksanthos" <taskin.balt...@gmail.com> wrote: >>> Hello, >>> >>> I'm working on an imaging system which uses C3188A digital cmos >>> camera(contains OV7620 image sensor). It is controlled by a PIC18F452 >and >>> each frame I want to view is stored in a FIFO buffer, AL422B. I can >store
How is data clocked into the FIFO, for 8 bit mode you will probably need glue logic/CPLD to ensure the data on rising and falling edges of PCLK are read correctly.
>>> a frame and transfer it to my PC by RS232. However I have a problem >with >>> the images, they look gray scale although they should be RGB. >>> I have configured OV7620 to transmit QVGA images in progressive mode. >I >>> haven't changed the data mode, it's repetitive because one-line output >>> format is not supported in qvga mode. The camera is configured to >output >>> raw data also.
I suspect you have not fully set RGB mode or 8 bit mode fully so the Y channel is outputting Y data (hint that is greyscale). Also I doubt you have set the FIFO (AL422B) to expect data on faster clock. So it may well be transmitting data either mainly green or Y which will appears as greyscale if only one half of the data is captured into the FIFO.
>><snip> >>Doesn't the OV7620 output pixels in the YUV colorspace by default? >>Are you commanding the sensor to switch to RGB mode (by sending an I2C >>cmd to change an internal register...I don't recall which one off the >>top of my head, but its clear in the datasheet)? Also, are you using >>both the Y pixel bus and the UV pixel bus, or just the Y pixel bus? >> >>Regards, >>John O >>www.jrobot.net >> >> >> >
-- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate