Main Site Documentation

How to get RGB matrices from picture taken from camera


#1

Hi, I would like to get the RGB matrices from the pictures taken from the camera module…
so far I have:

    void camera_PictureCaptured(Camera sender, GT.Picture picture)
        {
            Bitmap bmp = picture.MakeBitmap();

Is there any function like bmpToRGB or something like that?

Thanks.


#2

@ bioengproject - There is not a function that I know of (unless someone would like to share a known toolbox), however, if you take a look at how the Bitmap (careful, this is [em]NOT[/em] a BMP), you can write a function to place the image in a format of your choice.


#3

@ James - What is your opinion about the following:

      Bitmap bmp = picture.MakeBitmap();
            for (int i = 0; i < bmp.Height; i++)
            
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    GT.Color clr = bmp.GetPixel(i, j);
         
                    int red = clr.R;
                    int green = clr.G;
                    int blue = clr.B;
              }
}


#4

@ bioengproject - If this format is acceptable to your needs, then it looks logically sound to me. However, to cut down on size of the data type, you should use byte for each of the r/g/b variables.

We implement 16 bits per pixel, which leaves us with 5-6-5 bit count for r-g-b respectively.


#5

@ James - Thanks for reply. can you make some clarifications about that?
I didn’t understand =\


#6

In the code supplied above, the red green and blue values are stored as int. Due to our implementation, we only support 16bpp, which would allow you to store the data as a byte like so:

      Bitmap bmp = picture.MakeBitmap();
            for (int i = 0; i < bmp.Height; i++)
            
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    GT.Color clr = bmp.GetPixel(i, j);
         
                    byte red = (byte)clr.R;
                    byte green = (byte)clr.G;
                    byte blue = (byte)clr.B;
              }
}