So I think the endianness of the RGB565 Image data from the Spresense is either different from the Nicla Vision or the Arduino Example for it is wrong.
This is the code block from the example that converts RGB565 to RGB888:
bool RBG565ToRGB888(uint8_t *src_buf, uint8_t *dst_buf, uint32_t src_len)
{
uint8_t hb, lb;
uint32_t pix_count = src_len / 2;
for(uint32_t i = 0; i < pix_count; i ++) {
hb = *src_buf++;
lb = *src_buf++;
*dst_buf++ = hb & 0xF8;
*dst_buf++ = (hb & 0x07) << 5 | (lb & 0xE0) >> 3;
*dst_buf++ = (lb & 0x1F) << 3;
}
return true;
}
I saved the converted image buffer to a file on the MicroSD and then pulled them up in a python notebook.
When I use this block to covert a snapshot on Spresense I get very distorted colors:
However, when I switch the order of the bytes:
lb = *src_buf++;
hb = *src_buf++;
the colors are correct… and the model works as expected:
Could different sensors/vendor libraries be writing the image data down with different endianness?