gabriel.klein
Posts: 19
Joined: Mon Jul 28, 2014 1:50 pm

Red color in the middle of the camera

Wed Aug 13, 2014 9:03 am

Hi,

I use the raspberry to replace some of my landscape cameras.

You can see the result here
https://nuage.ch/site/montpreveyres/montpreveyres-6/
and here an infrared one (amazing)
https://nuage.ch/site/montpreveyres/webcam-montagnes-2/

The result is just amazing - but I still need to fine-tune my process :)

So one of my issues: If you see the middle of the image, it is more red
Image

I have the same issue with another raspberry camera.

If you see the same image in the middle of the night, the image is black. It means you don't have issues with the light of the camera (that was switched off) or of the board.

Image

To take the picture, I have the following parameters. It's the "optimal" I found to match with different luminosities during the day.

raspistill -awb auto -t 1000 --exposure auto -o - > imgtmp.jpg
convert -resize 50% -quality 90% imgtmp.jpg "${now}.jpg"

Any idea where this red hallow comes from?

Another issue is the "green effect".
Image
and one minute later
Image

With low luminosity, some images tend to be "green".

Note: It would be good to call "raspistill -awb auto -t 1000 --exposure auto -o -" and get the parameters to be used in other camera - So we can synchronize different cameras!
One of my test (with a mitigated success) was to have 2 cameras, and creating a landscape out of these 2 cams.

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 10:40 am

The colour could be related to http://www.raspberrypi.org/forums/viewt ... 50#p531150.

The settings could be extracted from the jpeg image and then transported to the other pi(i.e. with ssh keys to connect to pi2):
i.e.

Code: Select all

raspistill -w 1296 -h 972 -q 15 -t 1000 -o $now.jpg
settings=`strings ${now}.jpg | grep gain |\
 awk '{a=$6; b=$7;c=$3; split (a,aa,"=");  split(b,bb,"="); split(c,cc,"="); 
 print "-awb off -awbg "aa[2]","bb[2]" -ss "cc[2]}'`
ISO=`exif ${now}.jpg | grep ISO| awk -F"|" '{print $2}'`
ssh pi2 "raspistill -ISO $ISO -w 1296 -h 972 -q 15 -t 1000 $settings -o /where/ever/${now}.jpg"
this would set the same white balance and shutter speed and ISO value. (I have only one pi camera, so I can not test it.)

Edit: There is a bug at the moment which will result in wrong awb gains included in the jpeg, if -w and -h are used, then both gains are 1.
Last edited by ethanol100 on Wed Aug 13, 2014 4:25 pm, edited 1 time in total.

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 11:39 am

ethanol100 wrote:The colour could be related to http://www.raspberrypi.org/forums/viewt ... 50#p531150.
It's on the list, but is being a bit of a swine to pull across, and other things are currently higher priority (or higher chance of getting completed in time).
ethanol100 wrote:The settings could be extracted from the jpeg image and then transported to the other pi(i.e. with ssh keys to connect to pi2):
this would set the same white balance and shutter speed and ISO value. (I have only one pi camera, so I can not test it.)
Or use the camera settings callbacks to get the shutter speed, gains (need converting back into an ISO value), AWB gains, etc. Those can then all be punted across to the other Pi.
raspistill -set will print them out as they change.
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.

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 1:08 pm

6by9 wrote: Or use the camera settings callbacks to get the shutter speed, gains (need converting back into an ISO value), AWB gains, etc. Those can then all be punted across to the other Pi.
raspistill -set will print them out as they change.
Yes that would be perfect if we could set the gains ;)

And it is a bit complicated to judge which setting corresponds to the still capture and which corresponds to the preview settings. Taking the last setting should be ok. So I dream of using:

Code: Select all

settings=`raspistill -set -t 1000 -o ${now}.jpg 2>&1 |grep "mmal:" | tail -2 | awk '{gsub(/,/,"",$0);
    if(NR==1) {
       split($7,a,"/"); 
       split($10,b,"/"); 
       printf("-ss %d -exp off -expg %f,%f ",$4,a[1]/a[2],b[1]/b[2])  
      };
      if(NR==2){
       split($3,c,"=");
       split(c[2],cc,"/");
       split($4,d,"=");
       split(d[2],dd,"/");
       printf("-awb off -awbg %f,%f\n",cc[1]/cc[2],dd[1]/dd[1]);    
      }   
    }'`
ssh pi2 "raspistill $settings -o /somewhere/${now}.jpg"
If only the "-expg" could become true... :roll:

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 1:43 pm

gabriel.klein wrote:...
Another issue is the "green effect".
and one minute later
...

With low luminosity, some images tend to be "green".
You could store last few white balance gains and compare the actual ones with them, if there is a big change, you could repeat the capture with fixed gains extrapolated from the last ones. So you could create a hysteresis like slow changing white balance.

gabriel.klein
Posts: 19
Joined: Mon Jul 28, 2014 1:50 pm

Re: Red color in the middle of the camera

Wed Aug 13, 2014 1:56 pm

Thank you for the good tips. (I'll share my optimal solution, when I have one).

I want to work on two other aspects (low priority)
To do that you need similar parameters.

1)
Create a video of the day. You see the day in one minute.
So I need in this case some consistency in the parameters.

used_params(time+1) = 0.9 * used_params(time) + 0.1 * calculated_param(time+1)

Ideally you should have something like
used_params(time+1) = 0.45 * used_params(time) + 0.1 * calculated_param(time+1) + 0.45 * used_params(time)
but you need to know the future.... and it's a bit difficult :) but you can still have an idea based on a daily history (what was the evolution of the day yesterday.). It start to be a bit complex..

So you "soften" the transitions in your video. You don't see "jumps" in the image because you have a bird flying in front of your camera.

2)
Yearly video.

You see a video of the year by taking a daily picture at a specific time.

Every day you take a picture at a similar time based on the sunrise and sunset.
Exemple: middle of the morning
So your take a picture at 10:33am, 10:32 the next day.

But you still have "jumps" due to luminosity, so you need to post-process your data anyway.

Another approach is to take only "good transition pictures".
You remove a picture of a stormy day, because you have an unnatural frame in your video.

But I'm going too far (and my post is probably hard to read...)

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 2:07 pm

Additionally you could use the -ev value to capture series i.e. -8,-4,4,8 this would increase the possibility to find similar luminance, the white balance can be corrected with software relative easy. And to deliver a higher dynamic range, if necessary.

User avatar
KarlS
Posts: 42
Joined: Fri Oct 12, 2012 1:10 pm

Re: Red color in the middle of the camera

Wed Aug 13, 2014 2:40 pm

I've got the same issue (on three different camera modules). I first noticed the red center early December 2013 and mentioned it in my post http://www.raspberrypi.org/forums/viewt ... 17#p467517. Unfortunately I have deleted the winter image, so here is a current one - of a dull gray rainy morning:
Image Image
(the photo on the right was shot with a Panasonic Lumix for comparison)

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 3:27 pm

Can I just check, this is with a standard camera module with the normal lens? If not, then go and Google "lens shading".
The lens shading should be tuned reasonably for standard camera module/lens, whereas using one of the modified modules with CS mount or similar will need different settings.
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.

User avatar
KarlS
Posts: 42
Joined: Fri Oct 12, 2012 1:10 pm

Re: Red color in the middle of the camera

Wed Aug 13, 2014 3:30 pm

Yes, this is a standard camera module, not a modified one.

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

Re: Red color in the middle of the camera

Wed Aug 13, 2014 3:34 pm

I see something similar with my normal camera module, if I capture an image of my white ceiling:
Image

gabriel.klein
Posts: 19
Joined: Mon Jul 28, 2014 1:50 pm

Re: Red color in the middle of the camera

Thu Aug 14, 2014 7:11 am

It's a standard camera. No modification except the fact that the camera is in a waterproof case (an old projector).

I think the IR filter is guilty... I'll analyze that.

User avatar
KarlS
Posts: 42
Joined: Fri Oct 12, 2012 1:10 pm

Re: Red color in the middle of the camera

Mon Aug 25, 2014 11:57 pm

@Gabriel: Any news on the IR filter?

Anyway, I’m beginning to think it could be an “ageing” problem. I got my first camera module by end-August 2013 and it worked fine for a few months. In December it started to show the “red center”. I thought the module was broken so I ordered 2 new ones in February 2014. Again, both of them worked fine for a while until they started to show the “red center” in July. The modules are installed in a CCTV enclosure outside my house and they run headless 24/7 and take one picture every hour.

The effect is most noticeable when the sky is a dull gray (rain, snow, fog). If the sky is blue, the red center is barely noticeable.

Is it just a coincidence that my modules run fine for about 4 month and then start to show the “red center”???

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

Re: Red color in the middle of the camera

Tue Aug 26, 2014 7:53 am

Odd. Lens shading compensation should fix up the variations in colour across the lens/sensor. Not sure why it would change over time.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
algorithm
Posts: 190
Joined: Mon Nov 25, 2013 9:09 pm
Location: Flatland

Re: Red color in the middle of the camera

Tue Aug 26, 2014 9:27 am

Same problem here. Unmodified standard camera, latest firmware. Command line:

Code: Select all

raspistill -n -w 800 -h 600 -t 7200000 -tl 2000 -o /run/shm/webcam.jpg
webcam_20140826_112331.jpg
webcam_20140826_112331.jpg (32.1 KiB) Viewed 10931 times
EDIT: camera board purchased July 2013. Attached to RPi model A through replacement 300 mm cable.

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

Re: Red color in the middle of the camera

Tue Aug 26, 2014 5:57 pm

Does this happen with some cameras or all cameras? If it is the latter, is it possible that there was some firmware update that turned off a lens color-shading parameter that was previously on?

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

Re: Red color in the middle of the camera

Tue Aug 26, 2014 7:32 pm

Hmm, something is suspicious. I'll try and check it out tomorrow but I only have three days left in the office before we all get kicked in to touch!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

gabriel.klein
Posts: 19
Joined: Mon Jul 28, 2014 1:50 pm

Re: Red color in the middle of the camera

Tue Aug 26, 2014 7:51 pm

Sad if you are leaving. Raspberry Pi seams more popular than ever! Why do you have to leave?

I hope you will be able to find the reason of our issue and fix it :(

It might be a problem with the IR filter? Aging? High Temperature?

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Red color in the middle of the camera

Tue Aug 26, 2014 10:00 pm

gabriel.klein wrote:Sad if you are leaving. Raspberry Pi seams more popular than ever! Why do you have to leave?
http://www.raspberrypi.org/forums/viewt ... 62&t=83989

ddahms
Posts: 67
Joined: Tue Mar 18, 2014 3:38 pm

Re: Red color in the middle of the camera

Tue Aug 26, 2014 10:06 pm

The apparent "aging" may depend on when you last did a rpi-update. If you got firmware later than March 18, 2014, it has a problem with dynamic lens shading that was introduced in that release, explained in this post. 6x9 is trying to fix this before his time runs out. I hope he can.

User avatar
KarlS
Posts: 42
Joined: Fri Oct 12, 2012 1:10 pm

Re: Red color in the middle of the camera

Tue Aug 26, 2014 11:14 pm

@ddahms: Nope, that's probably not the problem. I'm running Raspbian with all the updates, but never did a rpi firmware update. And, I first had the problem in Dec '13, way before the rpi-update you mentioned that introduced an error.

As my cameras are sitting outside of my house (in the shade, working as weather-cams to record cloud formations), they're affected by changes in humidity and temperature, just to name a couple. In my location the ambient temperature can change by as much as 25°C day/night and the relative humidity can be as low as 20-30%.

Maybe
  • ... the sensor/lens package is not designed for this type of application
  • ... the IR filter gets unglued/warped over time
  • ... there is an error with the dynamic lens shading
  • ... (Sorry, I'm running out of ideas)

User avatar
DougieLawson
Posts: 38771
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Red color in the middle of the camera

Tue Aug 26, 2014 11:39 pm

KarlS wrote: I'm running Raspbian with all the updates, but never did a rpi firmware update.
There was a firmware update shipped as a stock standard apt-get update && apt-get upgrade. That's to the 3.12.22+ kernel which is the earliest level needed to support a B+. So you got one even without doing rpi-update.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Red color in the middle of the camera

Tue Aug 26, 2014 11:52 pm

Dougie's right 8-)
Typing

Code: Select all

zcat /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | more
on your Raspberry Pi will show you the update-history of the apt-get installed firmware (in reverse order, i.e. newest at the top). And 'vcgencmd version' will give you the version (and date) of your currently-running firmware.

User avatar
algorithm
Posts: 190
Joined: Mon Nov 25, 2013 9:09 pm
Location: Flatland

Re: Red color in the middle of the camera

Wed Aug 27, 2014 2:05 am

One more detail that came to mind: I have the camera LED switched off. Surely that's too small to need colour compensation? (Besides, I suppose that, if incorrectly compensating for a red light that's not there, the faulty colour would be the opposite of red.)

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Red color in the middle of the camera

Wed Aug 27, 2014 2:22 am

algorithm wrote:(Besides, I suppose that, if incorrectly compensating for a red light that's not there, the faulty colour would be the opposite of red.)
(and it would also be off to one side, rather than in the centre of the picture) ;)
Fairly sure that the LED is nothing to do with this though.

Return to “Camera board”