Hmm. so if i'm understanding you it seems that this sensor is outputting SGRBG8 instead of SBGGR right? In that case could you try the following patch. It should according to the sensor specs cause the sensor to start its readout one row later, giving you the expected BGGR layout hopefully....
On Sat, Jan 10, 2009 at 10:39 AM, wangrui <[email protected]> wrote: > >> And here I what I look like if you are a Clique Communications "Hue HD" cam. > > Hi, I bought nine HUE cameras yesterday. I will start working on it > until it can be used in linux. After some trying, I finally can see a > colored video now. I'm using the V4L2_PIX_FMT_SBGGR8 format, in the > source code it said > { > .pix_fmt = V4L2_PIX_FMT_SBGGR8, > .desc = "Bayer 8bit (BGGR)", > .depth = 8, > .set_format = sn9c20x_set_raw, > }, > It sounds like the pixel is arranged by BGGR. But after I tried, the > color pixel is actually arranged in the following way, > G R G R ... > B G B G ... > ... > > So the following java code can successfully decode it to a colored > picture, > private void decodeSBGGR8(byte[] bs, BufferedImage image) { > boolean evenRow = true; > int[][] is = new int[width + 2][height + 2]; > for (int y = 0; y < height; y++) { > for (int x = 0; x < width; x++) { > is[x][y] = bs[y * width + x] & 0xFF; > } > } > for (int y = 1; y <= height; y++, evenRow = !evenRow) { > boolean evenColumn = true; > for (int x = 1; x <= width; x++, evenColumn = > !evenColumn) { > int data = is[x][y]; > int lr = (is[x - 1][y] + is[x + 1][y]) >> 1; > int tb = (is[x][y - 1] + is[x][y + 1]) >> 1; > int r, g, b; > if (evenRow) { > // G R > // B G > if (evenColumn) { > r = lr; > g = data; > b = tb; > } else { > r = data; > g = (lr + tb) >> 1; > b = (is[x - 1][y - 1] + is[x + > 1][y - 1] > + is[x - 1][y > + 1] + is[x + 1][y + 1]) >> 2; > } > } else { > // G R > // B G > if (evenColumn) { > r = (is[x - 1][y - 1] + is[x + > 1][y - 1] > + is[x - 1][y > + 1] + is[x + 1][y + 1]) >> 2; > g = (lr + tb) >> 1; > b = data; > } else { > r = tb; > g = data; > b = lr; > } > } > int rgb = 0; > rgb = (r << 16) + (g << 8) + b; > rgb |= 0xFF000000; > image.setRGB(x - 1, y - 1, rgb); > } > } > } > > I can't find out how to decode V4L2_PIX_FMT_YUV420 and > V4L2_PIX_FMT_YUYV. And V4L2_PIX_FMT_JPEG returned an gray image. Maybe > there is some way to turn it into an colored image. > > Two important things are missing for this camera > 1. exposure. Currently the function dev->camera.set_auto_exposure and > dev->camera.set_exposure for MT9M111 are both NULL. > 2. change video size > > > > --~--~---------~--~----~------------~-------~--~----~ Lets make microdia webcams plug'n play, (currently plug'n pray) To post to this group, send email to [email protected] Visit us online https://groups.google.com/group/microdia -~----------~----~----~----~------~----~------~--~---
From 3c015e96e5fe5f1042c89a87444d7caed9b9aa6e Mon Sep 17 00:00:00 2001 From: Brian Johnson <[email protected]> Date: Mon, 12 Jan 2009 00:02:00 -0500 Subject: [PATCH] Start mt9m111 sensor readout 1 row later Signed-off-by: Brian Johnson <[email protected]> --- micron.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/micron.c b/micron.c index d9394bb..61013d6 100644 --- a/micron.c +++ b/micron.c @@ -300,7 +300,7 @@ struct sn9c20x_i2c_regs mt9m111_init[] = { /* The following set the resoutiona and window size. * It's a bit more than SXGA. * VSTART */ - {0x01, 0x000e}, + {0x01, 0x000f}, /* HSTART */ {0x02, 0x0014}, /* VSIZE */ @@ -326,6 +326,7 @@ struct sn9c20x_i2c_regs mt9m111_init[] = { {0x2d, 0x0188}, /* Green 2 gain */ {0x2e, 0x0188}, + {0x0d, 0x0008}, /* Blanking (again?) */ {0x0a, 0x0001}, {0x06, 0x0029}, -- 1.5.6.3
