cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Very magenta picture from NOiR camera when only light source is infrared

Tue Oct 15, 2019 1:38 pm

I'm looking at a weird situation with my NOiR camera v2. It behaves as it should unless any light source other than my IR flood light is present.

It seems to try to find an exposure but mostly (95%) of the time shows a fully magenta screen, where I can still make out movement but it's completely overblown.

Image

This is my backyard where you can see the leaves of the trees and they will be moving at the correct fps.

When I turn on a secondary non-IR light then it snaps back to a normal view, the IR is helping illuminate my yard just fine. But when I turn off the normal light the camera just keeps cycling some ranges of exposure (I guess) with the magenta image prodominatly in view.

I don't think this is a -awb greyworld issue, as I have tried that and all it seem to do is color the pink hue to a more black and white image. Not making the full magenta image go away.
Attachments
magentaNOIR.jpg
magentaNOIR.jpg (81.65 KiB) Viewed 2525 times

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Tue Oct 15, 2019 8:58 pm

Run sudo apt update && sudo apt dist-upgrade -y && sudo reboot to get the latest stable firmware, bootcode and kernel.
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.

cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Thu Oct 17, 2019 12:35 pm

Thanks but already did that, didn't solve it unfortunately

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Thu Oct 17, 2019 12:48 pm

Sticky at the top of the forum - New AWB algorithm - NoIR camera support
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
HermannSW
Posts: 2651
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Very magenta picture from NOiR camera when only light source is infrared

Thu Oct 17, 2019 4:29 pm

6by9 wrote:
Thu Oct 17, 2019 12:48 pm
Sticky at the top of the forum - New AWB algorithm - NoIR camera support
I did point out exactly that two days ago, but my response got deleted ...
https://stamm-wilbrandt.de/en/Raspberry_camera.html
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/raspiraw
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264

cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Oct 18, 2019 8:19 am

I did not delete any posts for sure.

But the sticky post is known, I did do the update, but it didn't solve the issue.

To clarify what happens:

My NOIR image is fine when a normal light source is present, it picks up the infrared illuminated scene plus some yellowish light from a normal source.
When I turn off the normal light source the camera goes into crazy mode and shows this full magenta screen most of the time, it cycles through some exposure levels it seems, one or two frames look good and then bam, this magenta version again. This happens over and over.

When I did the distro update and use the -awb greyworld setting, it simply colors the pink hue to a more back and white version. It does not prevent this magenta overexposure from happening.

But it seems nobody recognises this problem? So I guess my camera might be broken then?

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Oct 18, 2019 9:00 am

cleveridiot wrote:
Fri Oct 18, 2019 8:19 am
I did not delete any posts for sure.

But the sticky post is known, I did do the update, but it didn't solve the issue.

To clarify what happens:

My NOIR image is fine when a normal light source is present, it picks up the infrared illuminated scene plus some yellowish light from a normal source.
When I turn off the normal light source the camera goes into crazy mode and shows this full magenta screen most of the time, it cycles through some exposure levels it seems, one or two frames look good and then bam, this magenta version again. This happens over and over.

When I did the distro update and use the -awb greyworld setting, it simply colors the pink hue to a more back and white version. It does not prevent this magenta overexposure from happening.

But it seems nobody recognises this problem? So I guess my camera might be broken then?
This is a known thing - there should be loads of threads around with the fix. You need to set the greyworld AWB mode.
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.

cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Oct 18, 2019 10:34 am

I am going to assume I have done something wrong with the update then, and try to do it again.

Because as it seems nobody is reacting to what I am describing about what the update does and what my experience is, I am left to assume my update didn't work.

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Oct 18, 2019 10:40 am

You update will have been fine - but you need to specify the greyworld AWB algorithm when taking pictures.

https://www.raspberrypi.org/forums/view ... p?t=245994
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.

cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Oct 21, 2019 10:25 am

Ohh maybe that's the issue.

I am using raspiVID not the raspiSTILL as described in your sticky post, would that be the issue?

More specific, I'm outputting raspivid to VLC and streaming it in as an rtsp stream

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Oct 21, 2019 10:41 am

cleveridiot wrote:
Mon Oct 21, 2019 10:25 am
Ohh maybe that's the issue.

I am using raspiVID not the raspiSTILL as described in your sticky post, would that be the issue?

More specific, I'm outputting raspivid to VLC and streaming it in as an rtsp stream
AWB is the same for vid and stills, so you still need the appropriate runes for greyworld.
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.

cleveridiot
Posts: 10
Joined: Sun Sep 08, 2019 7:36 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Tue Oct 22, 2019 7:33 am

Right.. So, what could be the issue when I did all the things (upgrade and use of awb greyworld parameter) and the magenta screen still happens?

Could it be my flood light is too bright? Could it be that I have a wrong color infrared?

lsalvador
Posts: 2
Joined: Mon Jan 27, 2020 1:57 pm
Contact: Twitter

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Jun 12, 2020 1:50 pm

Hi, new in the forum.

I'm also using the PiNoir and facing the pink problem, my system information is:

Code: Select all

Linux RaspRingBell 4.19.118+ #1311 Mon Apr 27 14:16:15 BST 2020 armv6l GNU/Linux

I follow @DougieLawson instructions, aslo sudo rpi-update and I can see that the problem is fixed using the raspistill command:

Code: Select all

 raspistill -awb greyworld -o testAWB.jpg
I have a python script and try to do the same:

Code: Select all

with picamera.PiCamera(
framerate=15,
#sensor_mode=3
) as camera:
    camera.resolution = (2592,1944)
    camera.exposure_mode = 'sports'
    camera.awb_mode = 'greyworld'
    ....
After trying to execute the program, I can see the next system error in camera.py

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 3012, in _set_awb_mode
    mp.value = self.AWB_MODES[value]
KeyError: 'greyworld'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pro_LiveStream.py", line 93, in <module>
    camera.awb_mode = 'greyworld'
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 3014, in _set_awb_mode
    raise PiCameraValueError("Invalid auto-white-balance mode: %s" % value)
picamera.exc.PiCameraValueError: Invalid auto-white-balance mode: greyworld

Any tip to use the "greyworld" option on python ?

Thanks ¡¡
Lluis

User avatar
HermannSW
Posts: 2651
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Jun 12, 2020 5:34 pm

It is not implemented in picamera, so you need to implement it.

A month ago I did fork picamera and added new raspistill "--focus" feature:
https://github.com/Hermann-SW/picamera/ ... bc973225fb

You need to fork picamera, and add greyworld to EXPOSURE_MODES:
https://github.com/waveform80/picamera/ ... ra.py#L241
https://stamm-wilbrandt.de/en/Raspberry_camera.html
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/raspiraw
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264

lsalvador
Posts: 2
Joined: Mon Jan 27, 2020 1:57 pm
Contact: Twitter

Re: Very magenta picture from NOiR camera when only light source is infrared

Fri Jun 12, 2020 9:54 pm

HermannSW wrote:
Fri Jun 12, 2020 5:34 pm
It is not implemented in picamera, so you need to implement it.

A month ago I did fork picamera and added new raspistill "--focus" feature:
https://github.com/Hermann-SW/picamera/ ... bc973225fb

You need to fork picamera, and add greyworld to EXPOSURE_MODES:
https://github.com/waveform80/picamera/ ... ra.py#L241
Thanks for the quick answers Hermann, I don't have enough knowledge to implement it :_(

Do you know if this "greyworld" will be implemented in picamera in future standard release ?

Thanks,
Lluis

romney_yw
Posts: 17
Joined: Fri Apr 01, 2016 11:31 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Sat Jun 20, 2020 10:35 pm

6by9 wrote:
Thu Oct 17, 2019 12:48 pm
Sticky at the top of the forum - New AWB algorithm - NoIR camera support
In October 2019 the AWB_MODE "greyworld" was recommended for use with the NoIR camera.

Currently (June 2020), this works with the command line tools (e.g. raspistill), but as far as I can tell, the picamera Python library included in the current version of Raspberry Pi OS still does not support the "greyworld" option.

Can anyone suggest when the picamera Python library will be updated? It seems that the NoIR camera is unusable in Python until this is implemented....?

User avatar
HermannSW
Posts: 2651
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Very magenta picture from NOiR camera when only light source is infrared

Sat Jun 20, 2020 10:54 pm

romney_yw wrote:
Sat Jun 20, 2020 10:35 pm
Can anyone suggest when the picamera Python library will be updated?
Why not update yourself?
I did update picamera and added new "raspistill --focus" feature to picamera:
"Enhancing picamera with new MMAL features"
viewtopic.php?f=32&t=274168
Image
https://stamm-wilbrandt.de/en/Raspberry_camera.html
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/raspiraw
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Jun 22, 2020 9:42 am

If you are stuck with a library or application that doesn't support greyworld, then add "awb_auto_is_greyworld=1" (without the quotes) to config.txt. It does as it implies, and switches "auto" awb mode to select "greyworld" instead. That should be in firmware since March.
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.

romney_yw
Posts: 17
Joined: Fri Apr 01, 2016 11:31 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Jun 22, 2020 2:05 pm

HermannSW - many thanks for your very quick response to my post. Unfortunately - like lsalvador - I'm not sure I currently have the necessary expertise to implement this myself, at least partially because I don't understand the mysteries of Github and don't have the spare time to spend trying to fathom it out. I'm also a bit concerned about making my own version of a library which is included as part of the standard OS. What happens when the official version of the library is updated? Does my version prevent the official version from updating, or is my version simply overwritten when the OS is upgraded? If the updated version of the official library contains other changes, but still doesn't recognise the "greyworld" AWB_MODE, my changes will surely be lost, requiring me to edit the new library accordingly? Parallel development nightmare!

I update my Pis fairly often to keep the OS up-to-date, and I'm already having problems with losing my taskbar settings, desktop layout and file manager preferences whenever the desktop is updated. I can preserve my customised settings by not choosing a default setting (as instructed by the upgrade), but then I don't get the updated desktop settings (trivial though they sometimes appear to be....) I hesitate to take any action (e.g. with the picamera library) which can only make this situation worse than it already is! I'm working on some tools to help me maintain my desktop preferences, but as Simon Long indicated in the blog comments, this is by no means an easy task.... :shock:

6by9 - many thanks for the information about the "greyworld" switch in config.txt. I've read quite a lot of information about the new AWB algorithms and the magenta image problem with the NoIR camera, but I have somehow failed to notice that this switch is available. Given the recommendation in the sticky to always use "greyworld" with the NoIR camera, this seems to be the most straight-forward and elegant solution to this issue (for the time being at least....) I shall experiment forthwith.

User avatar
HermannSW
Posts: 2651
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Jun 22, 2020 6:53 pm

6by9 wrote:
Mon Jun 22, 2020 9:42 am
If you are stuck with a library or application that doesn't support greyworld, then add "awb_auto_is_greyworld=1" (without the quotes) to config.txt. It does as it implies, and switches "auto" awb mode to select "greyworld" instead. That should be in firmware since March.
Thanks for that information, and adding that to top pinned thread:
viewtopic.php?f=43&t=245994&p=1683597#p1683597

But many people missed that pinned thread in the past and asked on NoIR camera issues even after pinned thread was available. Can that be added to config.txt doc?
https://www.raspberrypi.org/documentati ... onfig-txt/
I could create a PR if that has chance of being accepted.
https://stamm-wilbrandt.de/en/Raspberry_camera.html
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/raspiraw
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264

romney_yw
Posts: 17
Joined: Fri Apr 01, 2016 11:31 am

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Jun 22, 2020 7:38 pm

Following the advice from 6by9, I have added the suggested line to my config.txt, immediately after "start_x=1" (which I believe is the line which loads the camera module - not to be confused with the command 'startx' which is how you run the desktop environment from the command line, or used to be a few versions back?)

I have not had chance to do any exhaustive testing, but my python script which was producing magenta images, now generates a much more realistically coloured picture. Result!

If I understand correctly, adding this line to config.txt makes the software use the "greyworld" settings as the default "auto" AWB_MODE on the camera - permanently. I assume that you could change the AWB_MODE to something else in your script, if you really wanted to. However, as mentioned earlier, the sticky suggests that you should always use "greyworld" with a NoIR camera. So add the line to config.txt as suggested and forget about AWB - at least until something else changes.....

Thanks again to 6by9, it appears that this has successfully resolved the problem with my camera. :D

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

Re: Very magenta picture from NOiR camera when only light source is infrared

Mon Jun 22, 2020 7:53 pm

HermannSW wrote:
Mon Jun 22, 2020 6:53 pm
6by9 wrote:
Mon Jun 22, 2020 9:42 am
If you are stuck with a library or application that doesn't support greyworld, then add "awb_auto_is_greyworld=1" (without the quotes) to config.txt. It does as it implies, and switches "auto" awb mode to select "greyworld" instead. That should be in firmware since March.
Thanks for that information, and adding that to top pinned thread:
viewtopic.php?f=43&t=245994&p=1683597#p1683597

But many people missed that pinned thread in the past and asked on NoIR camera issues even after pinned thread was available. Can that be added to config.txt doc?
https://www.raspberrypi.org/documentati ... onfig-txt/
I could create a PR if that has chance of being accepted.
Feel free to create a PR. We get a few contributions from the community on the docs repo, most get accepted in one way or another.
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
HermannSW
Posts: 2651
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Very magenta picture from NOiR camera when only light source is infrared

Tue Jun 23, 2020 1:54 pm

jamesh wrote:
Mon Jun 22, 2020 7:53 pm
Feel free to create a PR. We get a few contributions from the community on the docs repo, most get accepted in one way or another.
Thanks, done:
https://github.com/raspberrypi/documentation/pull/1600
https://stamm-wilbrandt.de/en/Raspberry_camera.html
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/raspiraw
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264

Return to “Camera board”