exposure and gain control

General discussion about topics related to OpenMV.
User avatar
chrisPyres66
Posts: 70
Joined: Mon Jul 16, 2018 9:22 am
Location: France

exposure and gain control

Postby chrisPyres66 » Tue Feb 12, 2019 11:39 am

Dear all,

As i use a small part of the image, i try to control the exposure and gain to have the highest contrast with different ambiant lights.

Is there a possibility to have the automatic gain and exposure control on a small part of the image ?
sensor.set_windowing((128,128)) only cut the image (white part is still white).

The gain is a float, and what is the minimum and maximum value (0.00001 to 9999.99999) ?
What about the exposure too (1 to 1960µs as said in OV7725 datasheet) ?

Thanks for help,
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Tue Feb 12, 2019 12:29 pm

Hi, the camera doesn't support gain/exposure for a small part of the image.

As for the min and maxes, the gain has a max of 32 or so. The exposure isn't really limited by anything. But, if you set it very high the FPS will go to near 0. The exposure is based on the pixel readout line times which we can be quite large.

Um, in the latest firmware I've been working on you'll be able to cut out an area of the image and then gamma adjust it in one line of code. Will this work for you? The gamma adjustment method can change gamma, contrast, and brightness in one go and is very fast.
Nyamekye,
User avatar
kwiley
Posts: 82
Joined: Fri Dec 21, 2018 5:22 pm

Re: exposure and gain control

Postby kwiley » Tue Feb 12, 2019 2:05 pm

I used to do long exposure astrophotography with modified webcams. We (the group that was into this) would perform circuit modifications of the webcam to enable manual control of the sensor shutter and then we could run very long exposures. I wrote pretty much the only and best (if I may say so) Mac software for controlling such modified cameras and for post-processing image stacks. Which all leads to my follow-up question in this thread. Are you really saying we have essentially long-exposure access to OpenMV simply by playing with the exposure setting? Can we leave the sensor exposing for seconds or even minutes? Just curious. I'll have to play with it, but I'm tantalized.
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Tue Feb 12, 2019 2:11 pm

The OV7725 has some digital hardware that blocks exposing forever, but, with the new global shutter sensor you can set the exposure to multiple seconds. Getting above minutes requires you to change the sensor clock freq which you can do if you edit the C firmware.
Nyamekye,
User avatar
kwiley
Posts: 82
Joined: Fri Dec 21, 2018 5:22 pm

Re: exposure and gain control

Postby kwiley » Tue Feb 12, 2019 7:50 pm

I already inquired about adding a global shutter module to my H7 preorder. I hope it all goes smoothly. :-) My initial project with the M7 has gone well, but I need more juice.
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Wed Feb 13, 2019 12:59 am

See: https://github.com/openmv/openmv/blob/m ... 034.c#L324

It looks like I range limit the exposure to half a second. However, you can do the register writes yourself in python to bypass this.

See page 18 for the register documentation:

https://www.onsemi.com/pub/Collateral/MT9V034-D.PDF

You'll need to adjust the clock freq if you want to get really high exposure values. This is just a value in a header file however:

https://github.com/openmv/openmv/blob/m ... v034.h#L12
Nyamekye,
User avatar
chrisPyres66
Posts: 70
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: exposure and gain control

Postby chrisPyres66 » Wed Feb 13, 2019 7:57 am

kwagyeman wrote:
Tue Feb 12, 2019 12:29 pm
Hi, the camera doesn't support gain/exposure for a small part of the image.

As for the min and maxes, the gain has a max of 32 or so. The exposure isn't really limited by anything. But, if you set it very high the FPS will go to near 0. The exposure is based on the pixel readout line times which we can be quite large.

Um, in the latest firmware I've been working on you'll be able to cut out an area of the image and then gamma adjust it in one line of code. Will this work for you? The gamma adjustment method can change gamma, contrast, and brightness in one go and is very fast.
Dear,

Thanks for your answer.

Yes gamma adjust seems to be like contrast adjust as well as i can understand, but latest firmware is for H7 because i use M7 up to i receive the H7 from kickstarter ?

Do you have an idea of the minimum of gain because it is a float and it could be very low but i am not sure if it is electronically possible ?

Thanks,
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Wed Feb 13, 2019 10:57 am

The latest firmware is for all camera versions.

The minimum gain is like 1/16th. It has fine steps of 1/16th and then large steps of 1 to 32.
Nyamekye,
User avatar
chrisPyres66
Posts: 70
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: exposure and gain control

Postby chrisPyres66 » Thu Feb 14, 2019 4:47 am

lol, ok you mean the last current firmware.

I am not sure which function does this gamma correction.
Is it the function for histogram ?

Thanks,
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Thu Feb 14, 2019 12:14 pm

Hi, no, I added a gamma correction method to the latest un-released firmware. I.e. what we are working on currently. It can do gamma, contrast, and brightness adjustment very fast. If this works for you I'll post the binary along with an example script.
Nyamekye,
User avatar
kwiley
Posts: 82
Joined: Fri Dec 21, 2018 5:22 pm

Re: exposure and gain control

Postby kwiley » Thu Feb 14, 2019 1:12 pm

Are we able to achieve a relatively flat gamma curve? Flat gamma, while often not pleasing to the eye, is very helpful in analysis.
User avatar
kwagyeman
Posts: 2713
Joined: Sun May 24, 2015 2:10 pm

Re: exposure and gain control

Postby kwagyeman » Thu Feb 14, 2019 1:41 pm

It's a general gamma correction method. So, you can apply whatever gain you want. If you need feedback based on the image use the get histogram method and change the gamma correction based on the histogram.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest