fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Bayer data from the NoIR camera

Fri Jun 08, 2018 3:29 pm

Hello everyone,

After spending all my day reading all the post about the bayer data and how to extract it with the --raw option or the picamera (bayer = True) i can't get the RAW output.

I use the Raw bayer data capture from here https://picamera.readthedocs.io/en/late ... a-captures, and when i try to visualize the output in GIMP all i get is that : Image

Which has nothing to do with my original image ? Why is that possible although the algorithme should be working for my case too, i cant see from where the probleme may come from.
I want also to know what does the rgb array contains at this point :

Code: Select all

rgb = np.zeros(data.shape + (3,), dtype=data.dtype)
rgb[1::2, 0::2, 0] = data[1::2, 0::2] # Red
rgb[0::2, 0::2, 1] = data[0::2, 0::2] # Green
rgb[1::2, 1::2, 1] = data[1::2, 1::2] # Green
rgb[0::2, 1::2, 2] = data[0::2, 1::2] # Blue
If i do add :

Code: Select all

rgb = ( rgb >> 2).astype(np.uint8) 
do i get the pure RAW output ? And when i print the rgb array what i see is 3x3 matrixes what does each one represent ?

I know it's all of questions but it has been 8 hours im on this and i'm a little bit confused :?


Thank you in advance.

HermannSW
Posts: 676
Joined: Fri Jul 22, 2016 9:09 pm

Re: Bayer data from the NoIR camera

Fri Jun 08, 2018 6:32 pm

I cannot help with picamera.
But raspiraw has no problems capturing raw Bayer data:
viewtopic.php?t=189661
This is a sample raw Bayer image without any processing:
Image


The top left image here shows part of that image scaled up:
Image
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 12:02 pm

Thank you for your reply,

I couldn't get raspiraw working, shoud i use the buildme file so that i can call the raspiraw command ? Or should i add it manually in the environment variable ?

For the picamera in python, the picture i posted before was the scaled up version of whole picture but what i get now is that :
Image

We can say its quite logic because i'm using a 650nm filter to thats the reason im having red ? but i was expecting the shapes of the real picture ..

Thank you.

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

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 1:05 pm

What was the problem with raspiraw?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

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

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 1:07 pm

That looks like the stride (the number of bytes to move down exactly one line) is wrong, so you're starting each line a couple of bytes late and so causing vertical lines to become diagonal.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 2:19 pm

Thanks for your answers guys,
jamesh wrote:What was the problem with raspiraw?
For raspiraw, i didn't get how do we build it ? The readme file doesn't specify any steps to perform in order to get the raspiraw command working, so when i'm lunching it i just get a bash error command not found. Sorry if it's supposed to be trivial but i'm just lost.
6by9 wrote: That looks like the stride (the number of bytes to move down exactly one line) is wrong, so you're starting each line a couple of bytes late and so causing vertical lines to become diagonal.
That seems interesting, matter of fact i changed the part of the code where we do an assert about the 4 first caracters of the header we should just have 'BRCM' or i had to change it to b'BRCM' because when i printed it there was a b before. Could it be that thats causing the desynchronization ? When you say the stride is wrong are you talking about the part where we affect the bayer pattern from the data array to our RGB array ?

HermannSW
Posts: 676
Joined: Fri Jul 22, 2016 9:09 pm

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 3:46 pm

> For raspiraw, i didn't get how do we build it ?
>
Sorry, I will have to update README.md, in addition to
https://github.com/6by9/raspiraw#raspiraw-usage

do:
viewtopic.php?f=43&t=189661&p=1232058#p1218763

Code: Select all

sudo apt-get install build-essential cmake
time ( ./buildme 2>err | tee out )

If /dev/i2c-0 is not present, you need these steps in addition:

Code: Select all

sudo apt-get install wiringpi
append  dtparam=i2c_vc=on  to /boot/config.txt
add  i2c-dev  to  /etc/modules-load.d/modules.conf
reboot
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

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

Re: Bayer data from the NoIR camera

Mon Jun 11, 2018 4:02 pm

fsxskillz wrote:
Mon Jun 11, 2018 2:19 pm
Thanks for your answers guys,
jamesh wrote:What was the problem with raspiraw?
For raspiraw, i didn't get how do we build it ? The readme file doesn't specify any steps to perform in order to get the raspiraw command working, so when i'm lunching it i just get a bash error command not found. Sorry if it's supposed to be trivial but i'm just lost.

Code: Select all

git clone git@github.com:6by9/raspiraw.git
cd raspiraw
./buildme
./camera_i2c
./raspiraw
You need to have added "i2c_vc=on" to /boot/config.txt and rebooted first.
fsxskillz wrote:
6by9 wrote: That looks like the stride (the number of bytes to move down exactly one line) is wrong, so you're starting each line a couple of bytes late and so causing vertical lines to become diagonal.
That seems interesting, matter of fact i changed the part of the code where we do an assert about the 4 first caracters of the header we should just have 'BRCM' or i had to change it to b'BRCM' because when i printed it there was a b before. Could it be that thats causing the desynchronization ? When you say the stride is wrong are you talking about the part where we affect the bayer pattern from the data array to our RGB array ?
The b'BRCM' may be a Python 2 to Python 3 change with the b meaning binary.
Pass - I don't do Python. Either stride being wrong would do it.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Tue Jun 12, 2018 10:46 am

Hello everyone,

So i tried raspiraw and dcraw here is what i do :

Code: Select all

./raspiraw -md 7 -t 1000 -ts tstamps.csv -hd0 hd0.32k -h 64 --fps 660 -o out.raw
Then i use dcraw in order to decode it

Code: Select all

./dcraw -v -w -H 1 -o 0 -q 3 -4 -T out.raw
But i get an error message : Cannot decode file out.raw .. It seems like i've done all the steps but i couldn't get my hand on the options of raspiraw et dcraw yet.

Thanks.

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

Re: Bayer data from the NoIR camera

Tue Jun 12, 2018 10:56 am

I think your options have written the header to a separate file to the raw data. That works for Hermann's tools, but not dcraw.

Either use -hd (not -hd0), or afterwards you can concatenate the header and raw into one file (cp hd0.32k combined.raw; cat out.raw >> combined.raw; ./dcraw combined.raw)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Tue Jun 12, 2018 1:05 pm

Thank you very much i'm starting to understand how all of this works, i managed to get the .ppm images.

I just wanted to ask you a question about the IR if i may.
I have the noIR camera and i add to it a 850nm filter, and if i think i understood that the bayer filter is composed of a red sensor filter a green filter and blue filter if there is another RGB filters on the sensor how do i manage to get an image from the 850nm ?

I noticed in the histogram of a photo taken by the camera + 850nm filter that all the colors have mean value of 150, i am interested in getting the ammount of light in the 850nm band ( the reflectance) how am i supposed to extract that information ?

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

Re: Bayer data from the NoIR camera

Tue Jun 12, 2018 1:36 pm

The spectral characteristics for IMX219 are in the datasheet - someone (not us) has put it on the web at https://github.com/rellimmot/Sony-IMX21 ... et_XXX.PDF
See page 87, Figure 45. Each pixel has a single colour filter over it, but all three become less effective as the wavelength gets longer, therefore the channels almost respond the same by the time you get out to 850nm. (Adding the IR filter just removes all of the IR band from all channels).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Thu Jun 14, 2018 1:26 pm

Thank you @6by9,

I was just wondering what was the default exposure time in raspiraw, i read somewhere that it was 200 microseconds but when i do -eus 200 i don't have the same result as with no -eus flag.

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

Re: Bayer data from the NoIR camera

Thu Jun 14, 2018 1:40 pm

fsxskillz wrote:
Thu Jun 14, 2018 1:26 pm
Thank you @6by9,

I was just wondering what was the default exposure time in raspiraw, i read somewhere that it was 200 microseconds but when i do -eus 200 i don't have the same result as with no -eus flag.
Sorry, I need to refer you back to the disclaimer - https://github.com/6by9/raspiraw/blob/m ... odes.h#L29

Code: Select all

// These values are copied from https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=162722&p=1052339
// Raspberry Pi can not discuss these settings as we have information from
// Sony under NDA.

// REQUESTS FOR SUPPORT ABOUT THESE REGISTER VALUES WILL
// BE IGNORED BY PI TOWERS.
It's not hard to work backwards from the register set to work out the value though.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

fsxskillz
Posts: 7
Joined: Fri Jun 08, 2018 2:55 pm

Re: Bayer data from the NoIR camera

Wed Jun 20, 2018 2:22 pm

Hello, thank you 6by9 and sorry i didn't see the disclaimer.

I just connected a Multicamera Board V2 to my raspberry pi and noticed that camera_i2c couldn't set the GPIO properly, is this normal ?

Thank you again !

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

Re: Bayer data from the NoIR camera

Wed Jun 20, 2018 2:37 pm

fsxskillz wrote:
Wed Jun 20, 2018 2:22 pm
I just connected a Multicamera Board V2 to my raspberry pi and noticed that camera_i2c couldn't set the GPIO properly, is this normal ?
Pass. There is no Multicamera Board made by Raspberry Pi (they're all 3rd party), therefore we'll make no guarantees on whether they'll work, or how they work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 6 guests