Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

How to turn off auto-anything?

Fri Jan 03, 2014 5:05 am

Hello,

I would like to turn off all auto-adjustments that the camera does. My use case is a scene with known constant illumination and very minor changes in the scene itself, and I see that even so the RPi camera keeps varying its exposure and white balance between successive stills or within a video, when using default settings.

Currently, there are --awb off to turn off auto white balance; and --ISO to turn off auto ISO. There is also --shutter. The combination of all three seems to give fully manual mode for stills. I think awb and ISO *do* work for video, but I'm not sure shutter does; I have tried changing the shutter setting up or down from 1000 to 100000 for video and it looks exactly the same.

Can anyone please answer whether it is possible to get fixed exposure for video, and if yes how? If it is not possible now, what parts of the code need to be changed?

Regards,
Rayden

P.S. Shouldn't raspistill be much faster (near instant) if all the auto adjustments are turned off?

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

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:30 am

Raspistill need to start up the camera, get it framing, do the adjustments, then take the picture. Even if you take out the adjustments, there is still quite a bit of startup time required.

If you want instant images, run raspistill in the background and signal it when you want to take pictures. That should be a lot faster.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:39 am

James,
Thank you for the reply. I am mainly interested in having fixed exposure/shutter speed throughout the video clip, so that the apparent illumination level never changes if the real level doesn't change. How can video exposure/shutter speed be set to a fixed value?
Thanks,
Rayden

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

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:42 am

I don't think its possible to turn off everything. You can set the shutter speed, ISO but some of the other settings are actually a pain to turn off. You can set a specific AWB mode which might help.

Just try settings!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:45 am

Thanks again. I have tried most combinations, raspistill shutter works, raspivid accepts the shutter option but there is no effect, it does auto-exposure anyway. I am quite interested in working on the code to make this happen (and also the other auto-settings which are "a pain to turn off", any hints what those are?) Could you point me in the right direction?

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

Re: How to turn off auto-anything?

Fri Jan 03, 2014 10:00 am

Rayden wrote:Thanks again. I have tried most combinations, raspistill shutter works, raspivid accepts the shutter option but there is no effect, it does auto-exposure anyway. I am quite interested in working on the code to make this happen (and also the other auto-settings which are "a pain to turn off", any hints what those are?) Could you point me in the right direction?
'raspistill --help' gives all the options, or there is the documentation in the raspi github where all the source code is.

You cannot simply change the shutter speed of video, since it is constrained by the frame rate (so max exposure of 33ms at 30fps). But you should be able to make it faster I think. reduce the frame rate to allow longer exposures in video.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: How to turn off auto-anything?

Fri Jan 03, 2014 3:01 pm

Actually, when using the V4l2 driver, the frame rate changes by virtue of the set manual exposure time. When I set exposure_time_absolute=10000 I get 1 fps.

Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:38 pm

jamesh wrote:'raspistill --help' gives all the options, or there is the documentation in the raspi github where all the source code is.
Yes, of course. I can't see any auto settings other than exposure, ISO, and awb though. What else gets auto-detected? Exposure (the different presets, eg night, sports...) seems to change more than just the shutter speed, -ex sports apparently uses a faster shutter (recorded in exif) at the same ISO than other modes for example. Could you explain how that works?
jamesh wrote:You cannot simply change the shutter speed of video, since it is constrained by the frame rate (so max exposure of 33ms at 30fps). But you should be able to make it faster I think. reduce the frame rate to allow longer exposures in video.
Yes, I quite understand that, fps sets an upper limit on shutter speed and vice versa. However, with latest raspivid, you cannot make shutter faster or slower, the --shutter setting has no effect on video at any fps. I was hoping you could help me figure out what to change in the code to make it have an effect as expected.

Regards,
Rayden

Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

Re: How to turn off auto-anything?

Fri Jan 03, 2014 9:39 pm

towolf wrote:Actually, when using the V4l2 driver, the frame rate changes by virtue of the set manual exposure time. When I set exposure_time_absolute=10000 I get 1 fps.
Interesting. Does the video also get brighter or darker? Any idea why/how this works in v4l2 but not raspivid? Does v4l2 also run on top of MMAL?

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

Re: How to turn off auto-anything?

Fri Jan 03, 2014 10:21 pm

Rayden wrote:
towolf wrote:Actually, when using the V4l2 driver, the frame rate changes by virtue of the set manual exposure time. When I set exposure_time_absolute=10000 I get 1 fps.
Interesting. Does the video also get brighter or darker? Any idea why/how this works in v4l2 but not raspivid? Does v4l2 also run on top of MMAL?
They are not quite the same, but do both run over MMAL I think, with maybe some bells and whistles added for good measure.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Rayden
Posts: 15
Joined: Fri Jan 03, 2014 4:23 am

Re: How to turn off auto-anything?

Tue Jan 07, 2014 12:01 pm

Rayden wrote:
towolf wrote:Actually, when using the V4l2 driver, the frame rate changes by virtue of the set manual exposure time. When I set exposure_time_absolute=10000 I get 1 fps.
Interesting. Does the video also get brighter or darker? Any idea why/how this works in v4l2 but not raspivid? Does v4l2 also run on top of MMAL?
Oh, just noticed: you said 1fps at 10000, but isn't exposure_time_absolute in milliseconds? The math doesn't work out, you are asking for 10 second exposure, the value must be getting clipped. What fps do you get at (say) exposure_time_absolute=500 or 100?

In any case this is promising, I haven't been able to try it out yet (can you post full command?) but I hope to give it a try soon.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: How to turn off auto-anything?

Tue Jan 07, 2014 12:30 pm

It is per 100usec. See here: http://www.raspberrypi.org/phpBB3/viewt ... 57#p471657

It actually exposes this long. I can get fairly good exposure in a dark room. The fps set on the video device is an upper bound, i.e., it never goes above 30fps if you set 30, but it goes slower depending what shutter speed is set.

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: How to turn off auto-anything?

Tue Jan 07, 2014 12:32 pm

I’m testing like this:

Code: Select all

root@alarmpi:~# cat  ./raspisend-rtx 
#!/bin/sh
#DEST="[2a02:8070:81a9:db00:221:6aff:fe08:c0e4]"
DEST=10.0.0.9

# tuning parameters to make the sender send the streams out of sync. Can be used
# ot test the client RTCP synchronisation.
#VOFFSET=900000000
VOFFSET=0
AOFFSET=0

VELEM="v4l2src do-timestamp=true"
VCAPS="video/x-h264,width=320,height=240,framerate=30/1"
VSOURCE="$VELEM ! $VCAPS"
VENC="h264parse ! rtph264pay"

VRTPSINK="udpsink port=5000 host=$DEST ts-offset=$VOFFSET name=vrtpsink"
VRTCPSINK="udpsink port=5001 host=$DEST sync=false async=false name=vrtcpsink"
VRTCPSRC="udpsrc port=5005 name=vrtpsrc"

gst-launch-1.0 -v rtpbin ntp-sync=true name=rtpbin \
    $VSOURCE ! $VENC ! queue ! rtpbin.send_rtp_sink_0 \
        rtpbin.send_rtp_src_0 ! $VRTPSINK \
        rtpbin.send_rtcp_src_0 ! $VRTCPSINK \
    $VRTCPSRC ! rtpbin.recv_rtcp_sink_0

Code: Select all

towolf@ovo:~$ cat .local/bin/raspirecv-rtx 
#!/bin/sh
VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"

VIDEO_DEC="rtph264depay ! h264parse ! avdec_h264"

VIDEO_SINK="fpsdisplaysink sync=false text-overlay=false"

# the destination machine to send RTCP to. This is the address of the sender and
# is used to send back the RTCP reports of this receiver. If the data is sent
# from another machine, change this address.
#DEST="[2a02:8070:81a9:db00:821f:2ff:fe82:3dd7]"
DEST=10.0.0.13

LATENCY=30

gst-launch-1.0 -vvv rtpbin name=rtpbin latency=$LATENCY ntp-sync=true do-retransmission=0 \
    udpsrc caps=$VIDEO_CAPS port=5000 ! rtpbin.recv_rtp_sink_0 \
      rtpbin. ! $VIDEO_DEC ! $VIDEO_SINK \
    udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 \
      rtpbin.send_rtcp_src_0 ! udpsink port=5005 host=$DEST sync=false async=false

With fpsdisplaysink you can see how many frames come in per second.

Change exposure with "v4l2-ctl -c exposure_time_absolute=10000" list with "v4l2-ctl -L"

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

Re: How to turn off auto-anything?

Tue Jan 07, 2014 12:47 pm

towolf wrote:It is per 100usec. See here: http://www.raspberrypi.org/phpBB3/viewt ... 57#p471657

It actually exposes this long. I can get fairly good exposure in a dark room. The fps set on the video device is an upper bound, i.e., it never goes above 30fps if you set 30, but it goes slower depending what shutter speed is set.
I don't see how its physically possible to expose, using the current camera driver, for more than 1s. (approx). The V4L driver uses the same camera driver as raspistill, and I wasn't able to go above 1s. Unless I have missed something somewhere. I wonder if the camera regs works in a different way depending on the line length or similar. Hmm. I'll have a think.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

towolf
Posts: 421
Joined: Fri Jan 18, 2013 2:11 pm

Re: How to turn off auto-anything?

Tue Jan 07, 2014 3:00 pm

No no, 10000 * 100 microseconds is the lower bound. I was merely talking about 1 second exposure times. It is even registered in the driver controls:

Code: Select all

         exposure_time_absolute (int)    : min=1 max=10000 step=1 default=1000 value=10000
Of course, if even longer times were possible I wouldn't complain.

By the way, is there any way that we could redefine the exposure presets like "night" to go even lower to 1s? Currently the lower bound is 1/4s, which is not long enough to warrant the label "night". Here it is pitch black as soon as the sun goes down (16:45 ish).

It makes sense not to offer very long expsoure time on mobile phones, but raspberry pis are rarely used handheld, in particular with this preset, I presume.

Image
Image

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

Re: How to turn off auto-anything?

Tue Jan 07, 2014 3:19 pm

I did spend some time trying to get exposures > 1s. It's actually a limitation of the sensor - the exposure register goes to about 1s. There are techniques to extend the line and frame lengths to give longer times. But when I tried this, everything else broke since the code isn't expecting that sort of behaviour. I'm sure with enough time something could be done. Just not right now.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

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

Re: How to turn off auto-anything?

Tue Jan 07, 2014 3:39 pm

towolf wrote: By the way, is there any way that we could redefine the exposure presets like "night" to go even lower to 1s? Currently the lower bound is 1/4s, which is not long enough to warrant the label "night". Here it is pitch black as soon as the sun goes down (16:45 ish).

It makes sense not to offer very long expsoure time on mobile phones, but raspberry pis are rarely used handheld, in particular with this preset, I presume.
I've taken a look at the tuning for night mode and it definitely doesn't take advantage of the new longer exposures. It also has a fairly low max gain (8x rather than 16x in some of the other modes). Might be able to get a bit more analogue and digital game in that mode to give better very low light performance (but noisy). I think this is indeed down to trying to keep handshake effect down to a minimum, but as you say, Raspi's don't normally go around handheld.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

sandrobotti
Posts: 1
Joined: Wed Jul 09, 2014 12:04 am

Re: How to turn off auto-anything?

Wed Jul 09, 2014 12:06 am

I have a question: can we disable all automatic settings in video mode? I've tried setting sh (0), co (0), br (50), sa (0), ISO (100), ev (0), ex (fixedfps), awb (off), awbg (1,1) to constant values, but the cam still automatically adjust itself to light intensity. Any ideas ?

Return to “Camera board”