Page 1 of 1

How to implement new sensor to openMV?

Posted: Fri Aug 17, 2018 8:30 am
by ssurneed
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;
}
}

Image

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

Re: How to implement new sensor to openMV?

Posted: Fri Aug 17, 2018 11:19 am
by kwagyeman
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.

Re: How to implement new sensor to openMV?

Posted: Mon Aug 20, 2018 3:41 am
by ssurneed
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.

Re: How to implement new sensor to openMV?

Posted: Mon Aug 20, 2018 11:29 am
by kwagyeman
Yeah, that method passes null to snapshot. Just return if called with null.

Re: How to implement new sensor to openMV?

Posted: Wed Aug 22, 2018 4:06 am
by ssurneed
kwagyeman wrote:
Mon Aug 20, 2018 11:29 am
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?

Re: How to implement new sensor to openMV?

Posted: Wed Aug 22, 2018 10:46 pm
by kwagyeman
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

Re: How to implement new sensor to openMV?

Posted: Thu Aug 23, 2018 9:12 am
by ssurneed
kwagyeman wrote:
Wed Aug 22, 2018 10:46 pm
Um that value is abused. It means a lot of different things in different contexts.
Ok, I got it