
Originally Posted by
holydivar
Adriano, would you mind sharing some more info. on how you displayed the photo from the serial data?
Writing a new image from the buffer sent over the serial:
Code:
byte[] aby = new byte[3];
int iBuffLen = Math.Min(4096, serialPort1.BytesToRead - (serialPort1.BytesToRead % 2));
int iBuffPos = 0;
serialPort1.Read(buffer, 0, iBuffLen);
while (iBuffPos < iBuffLen)
{
aby[0] = buffer[iBuffPos++];
aby[1] = buffer[iBuffPos++];
aby[2] = (byte)((aby[1] & 0x1F) * 8 + 7);
aby[1] = (byte)(((aby[1] >> 5) + ((aby[0] & 0x07) << 3)) * 4 + 3);
aby[0] = (byte)(((aby[0] & 0xF8) >> 3) * 8 + 7);
tempImage.SetPixel(iImagePixelIndex % 160, iImagePixelIndex / 160, Color.FromArgb(aby[0], aby[1], aby[2]));
iImagePixelIndex++;
if (iImagePixelIndex >= 160 * 120) iImagePixelIndex = 0;
}
pictureBox1.Image = tempImage;
If you want, I can send you the VS project - I didn't continued it, because it was to detect something on the cam and because the camera doesn't take photos but streams every single pixel, you can see the same (moving) object many times on the same frame.