JovianPyx
Posts: 132
Joined: Fri Nov 20, 2015 9:34 pm

V2 Camera Dead Time Between Timelapse Frames

Thu Jul 16, 2020 2:45 pm

I'm using a V2 camera for night sky work. It is connected to a pi4b 4G RAM with a USB HDD as root filesystem. It is a pi dedicated to the camera.

I am using raspiyuv to capture RGB data with this command:

Code: Select all

raspiyuv -n -ss 1000000 -t 40000 -ISO 800 -h 2464 -w 3280 -rgb  -tl 0 -o "image%06d.rgb"
This works, and I get good images (I use imagemagick convert command to convert to displayable format).

Time between frames, however, seems far too long.

First, if I run this with the 'time' command, real is 43.4 seconds when -tl is set to 40000 or 40 seconds.

EDITED: A misread of my screen had the image count at 5. It is 15.

But worse is the fact that during 40 seconds of operation, the camera takes only 15 images. Since the shutter speed is set to 1 second, I expected quite a few more images. in this case, each image is taking about 2.667 seconds to produce.

I've read the documentation about all of the camera software and I am having trouble locating what setting or setting I am using incorrectly or settings I may be missing.

I've read about the fact that some time is needed to transfer the data from the sensor chip over the cable and into RAM, however, I would expect this to be some milliseconds, not 1.667 seconds.

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

Re: V2 Camera Dead Time Between Timelapse Frames

Thu Jul 16, 2020 3:45 pm

Between each frame it is running the AGC and AWB. If you manually set those you can avoid that.

There's various threads on here about decreasing capture 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.

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

Re: V2 Camera Dead Time Between Timelapse Frames

Thu Jul 16, 2020 5:29 pm

I've covered enough times the mode switching that goes on with the camera stack, so I'm not going to repeat myself again.
Look into -bm (burst mode).
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.

JovianPyx
Posts: 132
Joined: Fri Nov 20, 2015 9:34 pm

Re: V2 Camera Dead Time Between Timelapse Frames

Thu Jul 16, 2020 6:00 pm

Thank you, the clues were AGC and AWB

Through research here and then a lot of experimentation, I found this to work quite well as a starting point:

Code: Select all

raspiyuv -o image%06d.rgb -n -ss 1000000 -t 60000  -h 2464 -w 3280 -rgb -ex off -tl 0 -awb off -bm -md 1 -ag 12.0 -awbg 1.3,1.3
This executes in 61.47 seconds and produces 59 images which is what I expected. Since I have an HQ camera as well, this gives me a leg up on doing the same with it.

For those reading and wondering what all of that does:

-awb off ........... turns off automatic white balance which reduces the time per image, but leaves the images very green.
-awbg 1.3,1.3 .. sets the blue and red gains to 1.3. This was a guess, but it worked well enough. More adjusting for those numbers later.
-ex off ............. exposure mode is off, but can leave the image under exposed.
-ag 12.0 .......... set the sensor's analog gain to 12.0 (the max) to compensate for -ex off
-md 1 .............. There's several modes which are fast, 1 is one of them, image quality seems unaffected by changing it, but brightness can be low

EDIT ADD:
I used

Code: Select all

raspistill -t0
to cause the camera to use it's default automatic controls including AWB. I then ran

Code: Select all

raspistill --settings
which has information about the red and blue gain settings. These are shown as fractions of integers over integers which I converted to floating point with a calculator. I then used those red and blue values in -awbg and I get satisfactory white balance. So I just used the camera to generate the values once, then turn off AWB and apply them all the time. Tweaking may be necessary, but it looks very good to me.

Here is a bash shell script I wrote to compute the floating point values from the integer fractions and display them. You can easily see the conditions under which white balance was computed.

Code: Select all

echo "starting camera in automatic mode"
raspistill -t 5000
echo "reading settings"
raspistill --settings 2> /tmp/settings

cat /tmp/settings | while read L1
  do
  read L2
  AG=$(echo "$L1" | cut -d',' -f2)
  AG=$(echo "$AG" | cut -d' ' -f4)
  AG=$(echo "scale=2; $AG" | bc -q)

  DG=$(echo "$L1" | cut -d',' -f3)
  DG=$(echo "$DG" | cut -d' ' -f4)
  DG=$(echo "scale=2; $DG" | bc -q)

  RED=$(echo "$L2" | tr '=,' '  ' | cut -d' ' -f4)
  RED=$(echo "scale=2; $RED" | bc -q)
  BLU=$(echo "$L2" | tr '=,' '  ' | cut -d' ' -f7)
  BLU=$(echo "scale=2; $BLU" | bc -q)

  echo -e "analog gain: $AG | digital gain: $DG \t| RED,BLUE: $RED,$BLU"
  done

rm /tmp/settings

Return to “Camera board”