Page 3 of 6

Re: Permanently turn AWB off

Posted: Tue Feb 11, 2014 10:36 pm
by Dillow
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

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 1:12 pm
by elnexo
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?

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 1:17 pm
by jamesh
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 7:27 pm
by Dillow
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:04 pm
by jbeale
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:26 pm
by Dillow
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:33 pm
by jamesh
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:41 pm
by Dillow
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:48 pm
by Dillow
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 8:54 pm
by waveform80
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 9:02 pm
by Dillow
[/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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 9:21 pm
by jbeale
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.

Re: Permanently turn AWB off

Posted: Wed Feb 12, 2014 11:10 pm
by ethanol100
You could try to help the awb algorithm with some colorfull stickers on the floor or the background.

Re: Permanently turn AWB off

Posted: Thu Feb 13, 2014 5:36 pm
by Dillow
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!

Re: Permanently turn AWB off

Posted: Fri Feb 14, 2014 6:55 pm
by BPK
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 :)

Re: Permanently turn AWB off

Posted: Sat Feb 15, 2014 9:44 am
by jamesh
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.

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 11:05 am
by Dillow
Any news on WB control? I still would need a way of turning AWB off and preferably setting a Kelvin value.

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 12:53 pm
by jamesh
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.

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 1:21 pm
by Dillow
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...

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 8:27 pm
by jamesh
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?

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 8:35 pm
by Dillow
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.

Re: Permanently turn AWB off

Posted: Thu Mar 13, 2014 11:12 pm
by poing
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.

Re: Permanently turn AWB off

Posted: Fri Mar 14, 2014 4:25 am
by tskwara
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.

Re: Permanently turn AWB off

Posted: Fri Mar 14, 2014 7:10 pm
by 6by9
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.

Re: Permanently turn AWB off

Posted: Fri Mar 14, 2014 8:32 pm
by Dillow
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.