ppumkin
Posts: 82
Joined: Tue May 29, 2012 10:22 pm

Camera exposure settings

Tue Jul 02, 2013 8:58 pm

When I set exposure to auto it is fine in the day. At night the picture is too dark.

If i set night- then its allot better.

How come auto does not try to adjust this? Is there something I am missing?

Code: Select all

 raspivid -ex auto -mm matrix -w 720-h 576 -fps 10 -t 0 -b 1000000 -o -

maddogdave
Posts: 46
Joined: Sat Dec 17, 2011 6:05 pm
Location: Berkshire England

Re: Camera exposure settings

Tue Jul 02, 2013 10:55 pm

I would say that what you have experienced applies to any form of digital imaging. Auto will operate over a range of light levels. Outside of this range then parameters will need adjustment. Hence why even the most complex of cameras don't always get the exposure spot on. Features such as backlight / highlight compensation, extended ISO settings and night modes aim to help compensate, as well as different metering modes and using exposure bracketing. I'm sure with some form of light sensor linked to a GPIO Input and a bit of code it would be possible to sense the ambient light level and let the Pi decide whether auto or night mode is best. But there will always be a compromise so unless you take multiple shots using various settings then there will be a point where changing modes or settings is required. Take for instance a security camera use, there will be a point where it needs to switch from day (auto) to night mode. Could be achieved on light level, time of day or by programming in a basic calendar to offset for sunrise & sunset times.
Dave

ppumkin
Posts: 82
Joined: Tue May 29, 2012 10:22 pm

Re: Camera exposure settings

Wed Jul 03, 2013 7:44 am

Thanks for answering. But that would mean that metering is redundant in this application, It would only be used once upon camera initialization and would never serve its purpose again.

Any modern digital camera has these metering options and in 'auto' mode the ISO and exposure is set by the meter. This is metered on each shot, after a sequence of shots or dynamically while recording a video.

So setting metering mode on the PiCam is pretty useless then if 'auto' mode is day only- it should be called day,night- etc - because there is no 'auto' functionality.

Using the light sensor is all and good- But a camera is a billion light sensors. Any body with the basic knowledge of using a digital camera will tell you that 'auto' means it will automatically set, aperture, exposure, ISO, auto white balance and most likely exposure. That is why professional camera cost so much because the metering algorithms inside the firmware take allot of experience and tweaking to get the desired effects in a set mode.

In this case it is nothing difficult.

- Auto mode should inspect the histogram and when it detects areas that are darker than xy% it should set the ISO higher and when it lightens drop the ISO. That is the only realistic solution to this problem.
- Night mode should have a fixed ISO (600) and a longer exposure (reducing frames but allowing to 'see' in the dark)

I know it is easy to say this and I am well aware that writting code for such a young platform is really difficult. I appreciete all the great work that has already been done.

I would never install a light meter to adjust script settings on the Pi- to stop and restart the camera. That is just not the correct way of doing it. Sure it is a short term resolution but its not a nice one.

It would be nice to see an API developed to allow for real time adjustments to the camera. That would allow for 3rd party programs to adjust the camera using its own algorithm based screen captures and other information. (It would also allow for paid application like Canon to develop closed source application for the Pi... just saying..)

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24989
Joined: Sat Jul 30, 2011 7:41 pm

Re: Camera exposure settings

Wed Jul 03, 2013 8:00 am

Please remember this is a camera and ISP designed for mobile phones. Their particular use cases are to work well for the person holding a camera in their hand. That requires that the device is always responsive (unless told otherwise); the problem with night mode is that is requires the ability to have very long exposure times (which requires special handling in the sensor, not just making some numbers bigger), which dramatically reduce responsiveness (very few frames/second if even that fast), and really knackers picture quality. This is simply not acceptable as a general use case for mobile devices, where the frame rate must be maintained at a sensible speed to keep the consumer happy. So the auto mode has limits on lower fps, which limits exposure, but keeps the camera working correctly in the majority of cases. Like many camera settings, there are always compromises.

So that's why the modes are separate. I suppose it would be possible to automatically switch modes if the camera detected it was too dark, but that's certainly not a use case requested by the usual customers of the cameras/ISP, which is why it is not there.

I would add that the camera system on the Pi is NOT a young platform, it's been in development for years, and is in millions of mobile phones - including the Nokia 808, which is/was regarded as the best camera phone available, although it does have a very expensive sensor in it.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

PiGraham
Posts: 3714
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Camera exposure settings

Wed Jul 03, 2013 8:17 am

Many compacts, as well as phone cameras, have a special night mode.

raspistill / raspivid seem to behave very like my Samsung phone. Night mode works in daylight. If you expect to need night mode some of the time you could turn it on all the time.

@JamesH, do you think the exposure mode could be changed on the fly by modifying the userland code? (I must find time to experiment with that code).

Maybe that would be a project for ppumpkin.

ppumkin
Posts: 82
Joined: Tue May 29, 2012 10:22 pm

Re: Camera exposure settings

Wed Jul 03, 2013 8:22 am

The Pi is a young system. Initially released as closed source and now opened?(Talking about the BCM chip- not linux or ARM) I realise the camera is a well established light array sensor used in many mobile devices and surveillance systems.

You are correct. The camera has not built in automatic tuning. But I never said it has. It is up to the software developer to determine the algorithm and control the camera. Like Nikon, Sony Alpha, Canon etc all work differently on 'auto' mode because each company has its own agenda to what is the best automatic picture. This algorithm is rolled out across various lenses and sensors.

Just like this Pi module is used in a Nokia or CCTV it is the actual software or driver that is responsible for doing all the settings. That is all I am saying. As it currently stands there is no way to tweak the settings without stopping and starting the camera. Did you ever have to stop the camera software on your Nokia Camera phone. set the ISO and effect. start the caemra application. No dont like it. Close the camera application. tweak the settings.. start the application.. ohh dammit segmentation fault.. WTF?! Reboot nokia phone... oh well there goes the sunset...

The camera use case is all and well and it is nailed 100%. I think its time to get to the users point of view and use cases for vendors and software to send API commands on the fly and adjust FPS, AWB,etc. There is no reason that it is not possible since every single camera phone and point and shooter does this already.

Besides- I left the camera running in 'night' mode during the day and its OK- So that is a bit odd that it is not overcompensated or bleached. I will wait and see if it looks ok at dusk again.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24989
Joined: Sat Jul 30, 2011 7:41 pm

Re: Camera exposure settings

Wed Jul 03, 2013 8:47 am

ppumkin wrote:The Pi is a young system. Initially released as closed source and now opened?(Talking about the BCM chip- not linux or ARM) I realise the camera is a well established light array sensor used in many mobile devices and surveillance systems.

You are correct. The camera has not built in automatic tuning. But I never said it has. It is up to the software developer to determine the algorithm and control the camera. Like Nikon, Sony Alpha, Canon etc all work differently on 'auto' mode because each company has its own agenda to what is the best automatic picture. This algorithm is rolled out across various lenses and sensors.

Just like this Pi module is used in a Nokia or CCTV it is the actual software or driver that is responsible for doing all the settings. That is all I am saying. As it currently stands there is no way to tweak the settings without stopping and starting the camera. Did you ever have to stop the camera software on your Nokia Camera phone. set the ISO and effect. start the caemra application. No dont like it. Close the camera application. tweak the settings.. start the application.. ohh dammit segmentation fault.. WTF?! Reboot nokia phone... oh well there goes the sunset...

The camera use case is all and well and it is nailed 100%. I think its time to get to the users point of view and use cases for vendors and software to send API commands on the fly and adjust FPS, AWB,etc. There is no reason that it is not possible since every single camera phone and point and shooter does this already.

Besides- I left the camera running in 'night' mode during the day and its OK- So that is a bit odd that it is not overcompensated or bleached. I will wait and see if it looks ok at dusk again.
I'm not entirely sure what you are getting at, but I'll try to explain further.

The Pi is new, but the camera subsystem it uses is very well established, it's the same as that used in the last of the Nokia Symbian phones (inlcuding 808), and also three new Samsung phones, the s2ve, the Grand Duos and another one I cannot remember the name of. The auto mode seems to be quite adequate for all those millions of devices, and both Nokia and SS are VERY picky about cameras.

Note that the GPU is NOT open source.

As for stopping the camera to change setting on your mobile - well, internally, that can be what it does - when you change a setting on a Nokia its quite possible the camera was stopped while the setting was changed. It's just that it wasn't stopped for very long - perhaps a mode change (camera run in different modes according to the requirements, and when you change modes you have to stop the camera and restart in the new mode) which drops a frame or two.

There are often very specific reasons why some settings CANNOT be changed on the fly - but of course some CAN be changed on the fly - just because the camera apps don't do it doesn't mean it cannot be done right now - try it and see what happens - you have the source for the apps. BUT, often changing settings like that will upset the rather convoluted algorithms going on inside the GPU . This is complicated stuff, and there are lots of interactions required between various parameters required to make the whole system work as required.

There is some work I need to do to expose some more settings (ISO, exposure time etc) but that's on a long list and its part time work. Things like AWB setting and other tuning parameters are unlikely in the short term to be available (there are thousands of parameters over the whole ISP)

As for using night mode during the day, should work OKish, but I would expect picture quality to be less than using auto mode, due to it being able to use longer exposures/and or higher gains, which have more noise.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

ppumkin
Posts: 82
Joined: Tue May 29, 2012 10:22 pm

Re: Camera exposure settings

Wed Jul 03, 2013 9:04 am

Yes. I know it is very complicated. And I appreciate everything we have already and know that people are working hard to make it better.

Possibly I can use nginx with rtmp-module to save keyframes and have something do my own analysis of the image and control the camera settings with start and stop. (Instead of adding another light sensor)

But starting and stopping the camera seems to upset something and sometimes I need to reboot to get it to work again.
The image looks fine in the day using night mode.(but I am in the UK and its always overcast) So I am not sure what the sun looks like.. um what it looks like on a sunny day.

I just thought I might be doing something wrong with the settings. But I can see there is still a long to get everything polished out.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: Camera exposure settings

Sat Jul 06, 2013 8:44 am

Night mode always works during the day. The only thing it does, as far as I can determine, is to unlock the framerate from 30fps and make framerates variable in a range between 30 fps and 4 fps. Now you might not want your frame rates to be variable since many video applications expect fixed framerates.

Personally I’d like this lower bound of 4 fps to be even lower. I’d guess that most people here are not hand holding their camera but it is usually mounted somewhere and camera shake is not to be expected. Long exposure times do not have other drawbacks. They certainly don’t reduce picture quality (ISO does), but they enhance SNR due to more signal coming in.

ppumkin
Posts: 82
Joined: Tue May 29, 2012 10:22 pm

Re: Camera exposure settings

Sat Jul 06, 2013 8:59 am

I use it for motion detection on a server running ispy. Quite a neat piece if open source software. That can handle variable frame rate and even if it drops to 4fps or 2fps but it had a longer exposure with a 200/400 iso that would be much better quality than a normal exposure on 800 iso. Either way it would be nice to adjust anything via an api. Writing a plugin to ispy would be trivial then.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24989
Joined: Sat Jul 30, 2011 7:41 pm

Re: Camera exposure settings

Sat Jul 06, 2013 9:20 am

I just pushed a change to enable ISO setting - I tried it and certainly the EXIF data reflected the specified ISO - whether it actually uses that ISO I leave for others to test.

For those that cannot wait for it to get to userland, there is a commented out line on RaspiCamCOntrol.g where the setting of ISO is disabled - reintroduce that line.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Return to “Camera board”