> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to