How to implement new sensor to openMV?

Discussion related to "under the hood" OpenMV topics.
ssurneed
Posts: 8
Joined: Thu Jun 14, 2018 5:51 am

How to implement new sensor to openMV?

Postby ssurneed » Fri Aug 17, 2018 8:30 am

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
Attachments
m2.jpg
m2.jpg (54.05 KiB) Viewed 423 times
User avatar
kwagyeman
Posts: 2462
Joined: Sun May 24, 2015 2:10 pm

Re: How to implement new sensor to openMV?

Postby kwagyeman » Fri Aug 17, 2018 11:19 am

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.
Nyamekye,
ssurneed
Posts: 8
Joined: Thu Jun 14, 2018 5:51 am

Re: How to implement new sensor to openMV?

Postby ssurneed » Mon Aug 20, 2018 3:41 am

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.
User avatar
kwagyeman
Posts: 2462
Joined: Sun May 24, 2015 2:10 pm

Re: How to implement new sensor to openMV?

Postby kwagyeman » Mon Aug 20, 2018 11:29 am

Yeah, that method passes null to snapshot. Just return if called with null.
Nyamekye,
ssurneed
Posts: 8
Joined: Thu Jun 14, 2018 5:51 am

Re: How to implement new sensor to openMV?

Postby ssurneed » Wed Aug 22, 2018 4:06 am

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?
User avatar
kwagyeman
Posts: 2462
Joined: Sun May 24, 2015 2:10 pm

Re: How to implement new sensor to openMV?

Postby kwagyeman » Wed Aug 22, 2018 10:46 pm

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
Nyamekye,
ssurneed
Posts: 8
Joined: Thu Jun 14, 2018 5:51 am

Re: How to implement new sensor to openMV?

Postby ssurneed » Thu Aug 23, 2018 9:12 am

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

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests