How to implement new sensor to openMV?

I want to add a new sensor in OpenMV
Can you tell more about the structures image_t and framebuffer_t ??
I added some code to the function
int sensor_snapshot(sensor_t *sensor, image_t *image)
and I hoped to get a black picture

uint8_t *src = MAIN_FB()->pixels;

for (uint32_t h = 1; h < MAIN_FB()->h + 1; h++) {
for (uint32_t w = 0; w < MAIN_FB()->w; w++) {

src[w*h] = 0;
}
}

but for some reason it did not work out.

I go in small steps, the first step is to change the image from the sensor to the static image from the file.
Then I wiil add a new sensor.

I hope for your answer.
Have a nice day
m2.jpg

Hi, there are multiple image types. Images can be 1 byte per pixel or two. Please see all the image processing methods. Like, for example, look at the code in filter.c or etc. They show how to access the pixels in an image.

Hi kwagyeman
I found a problem, this function calls sensor_snapshot with the NULL parameter
sensor.skip_frames(time = 2000) # Wait for settings take effect.

Yeah, that method passes null to snapshot. Just return if called with null.

// Fix the BPP
switch (sensor->pixformat) {
case PIXFORMAT_GRAYSCALE:
MAIN_FB()->bpp = 1;
break;
case PIXFORMAT_YUV422:
case PIXFORMAT_RGB565:
MAIN_FB()->bpp = 2;
break;
case PIXFORMAT_BAYER:
MAIN_FB()->bpp = 3;

break;
case PIXFORMAT_JPEG:
// Read the number of data items transferred
MAIN_FB()->bpp = (MAX_XFER_SIZE - __HAL_DMA_GET_COUNTER(&DMAHandle))*4;
break;
default:
break;
}

I was slightly confused, I thought that the format PIXFORMAT_BAYER has one byte per pixel?

Um that value is abused. It means a lot of different things in different contexts.

0 → Binary Image
1 → Grayscale (1 byte per pixel)
2 → RGB565 (2 bytes per pixel)
3 → Bayer
4 >= → Jpeg byte count

Ok, I got it