Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Tue Feb 11, 2014 10:36 pm

Just to jump into the scrum here I am working on a photo booth project where I have controlled light temp and desperately need to be able to set a fixed white balance in Kelvin or worst case just off. In every awb setting I have tried via Raspistill I get wide swinging white balance based off the colors picked up by the camera.

Thanks Chris

elnexo
Posts: 6
Joined: Tue Feb 04, 2014 9:33 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 1:12 pm

jamesh wrote:...Woud be nice to be able to use a fixed CCM but fas with all these things its finding the time to implement it on the GPU and expose the controls to the ARM. Its quite long-winded.
I understand that this takes time and you guys are pretty busy. I would be more than glad to look through the code and hopefully some kind of documentation if it was available to me. Maybe I am lucky and I find some hints that make it quicker for you to get the feature implemented. Or is there any other way I can help?

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

Re: Permanently turn AWB off

Wed Feb 12, 2014 1:17 pm

The code is closed source, so not available I am afraid.

But the main problem if access were available would be the incredible complexity of the code. I've been working off and on the camera code for 3 years, and I still cannot figure out how most of it works.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 7:27 pm

Until the smart guys who have access to the code can work on this issue does anyone have any suggestions as to how to make the awb more consistent when using Raspistill? I need fast still image capture so processing the raw is not a good option for me. Here is an example of what I am running into. It is a wild swing in WB and if I can't make it more consistent it could kill my project or at least the use of the PI camera module. I have tried all the settings in Raspistill but any suggestions will be welcome please!!

This is a bad WB
Image

This is a good WB or at least what I would like to get every time. The lights are daylight balanced.
Image

Thanks in advance for any suggestions. I am about to build a full sized photo booth for cars using 12-16 PI s and this is the only real issue I have run into. Excuse the blurry images the PI is too close to the car in my scale model booth, will not be an issue in a full sized booth.

User avatar
jbeale
Posts: 3494
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:04 pm

Supposedly it is possible to turn off white balance for a *single frame* after which it bounces back again. But if you just need a single frame, maybe that is OK. This post claims it is possible to get 20 fps (perhaps at low resolution?) with the requirement to call "AWB OFF" before each frame. If this actually works, it seems straightforward to modify raspistill to do this immediately prior to capturing the still frame. (The preview would not be affected so it would still have AWB active.)

http://www.raspberrypi.org/phpBB3/viewt ... 28#p465637
we are using robidouille (wrapper for opencv) to capture frames.

In robidouille/raspicam_cv.c
we added this method:
void set_awb_off() {
raspicamcontrol_set_awb_mode(camera, 0);
}
To take a snapshot, we wrapped it in a nice little method that sets awb off, then takes a new image
(include raspicamvc)
IplImage* snapshot(RaspiCamCvCapture *capture) {
set_awb_off();
return raspiCamCvQueryFrame(capture);
}

you need to call awb off for every frame. We still get 20fps with this implementation.

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:26 pm

jbeale wrote:Supposedly it is possible to turn off white balance for a *single frame* after which it bounces back again. But if you just need a single frame, maybe that is OK. This post claims it is possible to get 20 fps (perhaps at low resolution?) with the requirement to call "AWB OFF" before each frame. If this actually works, it seems straightforward to modify raspistill to do this immediately prior to capturing the still frame. (The preview would not be affected so it would still have AWB active.)

http://www.raspberrypi.org/phpBB3/viewt ... 28#p465637
we are using robidouille (wrapper for opencv) to capture frames.

In robidouille/raspicam_cv.c
we added this method:
void set_awb_off() {
raspicamcontrol_set_awb_mode(camera, 0);
}
To take a snapshot, we wrapped it in a nice little method that sets awb off, then takes a new image
(include raspicamvc)
IplImage* snapshot(RaspiCamCvCapture *capture) {
set_awb_off();
return raspiCamCvQueryFrame(capture);
}

you need to call awb off for every frame. We still get 20fps with this implementation.

Thanks I will look into robidouille. After a few mins of looking at it I would be concerned it is more for snagging video frames and I am looking to capture 5 MP images at as high a quality as I can get from the PI camera. But I did not spend much time with it and maybe it does more then I know. Thanks for the suggestion.

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

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:33 pm

What I dont understand is why you are seeing swings in WB under constant lighting conditions. It should stay constant.

We did find some crappy code in the camera driver to do with exposure whist getting 60fps working, so I wonder if that might be affecting it. Once I get a new camera tomorrow I'll try and sort the crap out - I static shocked mine in to oblivion.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:41 pm

jamesh wrote:What I dont understand is why you are seeing swings in WB under constant lighting conditions. It should stay constant.

We did find some crappy code in the camera driver to do with exposure whist getting 60fps working, so I wonder if that might be affecting it. Once I get a new camera tomorrow I'll try and sort the crap out - I static shocked mine in to oblivion.

I would expect the same also but as you can see it goes crazy. I even switched out camera modules out thinking I had a bad one. Same thing. I have noticed that the color of the car I am shooting makes it behave differently (I have no issues with Red cars) even though the light and background stays the same. Not sure where it is sampling for awb in the frame. I tried different light metering modes to see if I could affect the WB but I have no idea if the light metering and sampling done for WB are at all connected. Does not seem to be.

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:48 pm

Dillow wrote:
jamesh wrote:What I dont understand is why you are seeing swings in WB under constant lighting conditions. It should stay constant.

We did find some crappy code in the camera driver to do with exposure whist getting 60fps working, so I wonder if that might be affecting it. Once I get a new camera tomorrow I'll try and sort the crap out - I static shocked mine in to oblivion.

I would expect the same also but as you can see it goes crazy. I even switched out camera modules out thinking I had a bad one. Same thing. I have noticed that the color of the car I am shooting makes it behave differently (I have no issues with Red cars) even though the light and background stays the same. Not sure where it is sampling for awb in the frame. I tried different light metering modes to see if I could affect the WB but I have no idea if the light metering and sampling done for WB are at all connected. Does not seem to be.

See if I shot Red cars thee are no problems 8-)
Image
Image

I am sure others would like the awb to be more consistent but again I would be externally grateful if I could just set a fixed WB value and forget it. I am sure making the awb work more consistently would be a much harder nut to crack.

User avatar
waveform80
Posts: 303
Joined: Mon Sep 23, 2013 1:28 pm
Location: Manchester, UK

Re: Permanently turn AWB off

Wed Feb 12, 2014 8:54 pm

Dillow wrote:
Dillow wrote:
jamesh wrote:What I dont understand is why you are seeing swings in WB under constant lighting conditions. It should stay constant.

We did find some crappy code in the camera driver to do with exposure whist getting 60fps working, so I wonder if that might be affecting it. Once I get a new camera tomorrow I'll try and sort the crap out - I static shocked mine in to oblivion.

I would expect the same also but as you can see it goes crazy. I even switched out camera modules out thinking I had a bad one. Same thing. I have noticed that the color of the car I am shooting makes it behave differently (I have no issues with Red cars) even though the light and background stays the same. Not sure where it is sampling for awb in the frame. I tried different light metering modes to see if I could affect the WB but I have no idea if the light metering and sampling done for WB are at all connected. Does not seem to be.

See if I shot Red cars thee are no problems 8-)
Image
Image

I am sure others would like the awb to be more consistent but again I would be externally grateful if I could just set a fixed WB value and forget it. I am sure making the awb work more consistently would be a much harder nut to crack.
When the AWB goes nuts, is it for a single frame (i.e. it's coincidental that you happen to capture at the point the AWB goes nuts), or is it over several frames. More specifically, is it likely that you'd capture an image with an incorrect AWB more than once in a row? If not, then taking the median values from three consecutive images might be a way of working around the issue (for now), given that median is a reasonably common method for discarding outliers. Obviously this would also slow down your capture rate, so that's another thing to consider...

Dave.

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 9:02 pm

[/quote]


See if I shot Red cars thee are no problems 8-)
Image
Image

I am sure others would like the awb to be more consistent but again I would be externally grateful if I could just set a fixed WB value and forget it. I am sure making the awb work more consistently would be a much harder nut to crack.[/quote]

When the AWB goes nuts, is it for a single frame (i.e. it's coincidental that you happen to capture at the point the AWB goes nuts), or is it over several frames. More specifically, is it likely that you'd capture an image with an incorrect AWB more than once in a row? If not, then taking the median values from three consecutive images might be a way of working around the issue (for now), given that median is a reasonably common method for discarding outliers. Obviously this would also slow down your capture rate, so that's another thing to consider...

Dave.[/quote]


When it off it seems to be consistently off for me. I can shoot the same frames over and over and get similar results for the most part. I am not doing previews as the PIs are headless. So not sure what the Preview looks like. Have it set off right now.

User avatar
jbeale
Posts: 3494
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Permanently turn AWB off

Wed Feb 12, 2014 9:21 pm

just to add in another factor: some kinds of fluorescent lights (and other gas-discharge type bulbs) can change color temperature significantly throughout one half cycle of the AC power line frequency. The result is images in bright light taken with short shutter speeds can change color balance seemingly at random, depending on the phase of the AC powerline at the moment of exposure. If you are using a slow shutter speed, or a high-frequency CF bulb, incandescent, LED, or natural outdoor light then this would not apply.

Using blue LED light on a static image, I have also observed sudden white-balance shifts, so the camera module can definitely do that even with unchanging light.

ethanol100
Posts: 585
Joined: Wed Oct 02, 2013 12:28 pm

Re: Permanently turn AWB off

Wed Feb 12, 2014 11:10 pm

You could try to help the awb algorithm with some colorfull stickers on the floor or the background.

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Thu Feb 13, 2014 5:36 pm

ethanol100 wrote:You could try to help the awb algorithm with some colorfull stickers on the floor or the background.

Thats a good suggestion I will try it. Thanks!

BPK
Posts: 30
Joined: Mon Jun 04, 2012 10:12 am
Location: Bristol, United Kingdom
Contact: Website

Re: Permanently turn AWB off

Fri Feb 14, 2014 6:55 pm

jamesh wrote: We did find some crappy code in the camera driver to do with exposure whist getting 60fps working
Can't help but notice the past tense on the getting 60fps working... Don't suppose wider FOV solution can also be talked about as a problem solved :)
Barnaby Kent
http://www.pi-cars.com
Control your radio controlled car through your Raspberry Pi

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

Re: Permanently turn AWB off

Sat Feb 15, 2014 9:44 am

I have a feeling once we sort of the dodgy exposure code we found, then the new modes should follow quickly. We did quickly try 90 but that certainly didn't work though.

Unfortunately my camera has broken so I cannot do any work on this at the moment.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Thu Mar 13, 2014 11:05 am

Any news on WB control? I still would need a way of turning AWB off and preferably setting a Kelvin value.

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

Re: Permanently turn AWB off

Thu Mar 13, 2014 12:53 pm

We have not been working on it - full FOV video (720p) and 60fps VGA is where the time is being spent. These should be soon.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Thu Mar 13, 2014 1:21 pm

OK Thanks for the update. This WB issue may kill my project in terms of using the Pi/Camera. Is there anything I can do? Bribes etc... ;) I have a controlled environment using a fixed color temp. What I need is to be able to set the color temp at 5500k. I will beg if needed...

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

Re: Permanently turn AWB off

Thu Mar 13, 2014 8:27 pm

Hmm. I'll have a word with the AWB experts to see what is actually possible.

Just for my reference, questions to all those asking for AWB changes..

1) What wrong with the current system?
2) What additional features do you want?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Thu Mar 13, 2014 8:35 pm

I believe my request is close to the original posters request. To turn off AWB. Which to me implies setting a fixed kelvin value. It would be nice to be able to specify that value via a pram. The act of that would completely disable AWB or at least ignore it.

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

Re: Permanently turn AWB off

Thu Mar 13, 2014 11:12 pm

jamesh wrote:Hmm. I'll have a word with the AWB experts to see what is actually possible.

Just for my reference, questions to all those asking for AWB changes..

1) What wrong with the current system?
2) What additional features do you want?
To be able to make accurate images, where you know the light level and light color, you don't want anything auto messing up your output because the scene changes. We now have the exposure covered (ISO plus ss) but the color is still unreliable.

Think making timelapses, stitching panoramas, accurately shooting series of images and scientific uses. It would be a great day if the color would be stable.

User avatar
tskwara
Posts: 81
Joined: Fri Feb 15, 2013 4:16 pm
Location: Orchard Park, NY USA
Contact: Website

Re: Permanently turn AWB off

Fri Mar 14, 2014 4:25 am

Perhaps allowing the preload of a reference image file (i.e. gray card) to the frame buffer and using existing white balance calculations can provide the desired results? Once gain adjustments are calculated, the AWB mode would be set to CUSTOM and the adjustments remain constant for subsequent frames...

A simpler approach may be to facilitate the read/write of gain values along with a AWB_CUSTOM mode that skips calculations on subsequent frames.
MobileApp Systems
Mobile Applications on a Mission

Makers of Proto Armour for Raspberry Pi
Explore Proto Armour / www.protoarmour.com

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7312
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Permanently turn AWB off

Fri Mar 14, 2014 7:10 pm

poing wrote:
jamesh wrote:Hmm. I'll have a word with the AWB experts to see what is actually possible.

Just for my reference, questions to all those asking for AWB changes..

1) What wrong with the current system?
2) What additional features do you want?
To be able to make accurate images, where you know the light level and light color, you don't want anything auto messing up your output because the scene changes. We now have the exposure covered (ISO plus ss) but the color is still unreliable.

Think making timelapses, stitching panoramas, accurately shooting series of images and scientific uses. It would be a great day if the color would be stable.
Could you confirm what you are capturing with, and how?
I've just had a quick check having dumped extra logging into the GPU. Using "raspistill ... -awb off -o foo.jpg", during preview AWB calculates gains once at the very start of preview, but it does recalculate on the capture too. That surprises me a little and I wasn't expecting, but I'd like you to confirm that that is the mode that you are working in before I start looking in any more detail.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Dillow
Posts: 27
Joined: Tue Feb 11, 2014 10:25 pm

Re: Permanently turn AWB off

Fri Mar 14, 2014 8:32 pm

I am using Rasipstill AWB off I can supply the whole command line if you want it.

I have noticed the same. the Preview seems to change from Frame to Frame and the capture does not always match the end of the preview.

Return to “Camera board”