Skip to content

Capture

Lukáš Karas edited this page Jan 28, 2016 · 3 revisions

Tool for capture sequence of images from digital camera (V4L or GPhoto2 API). This tool support automatic shutter speed configuration with some gphoto2 cameras. It is useful when light conditions are changing during timelapse capturing.

Usage: timelapse_capture [options]
Tool for capture sequence of images from digital camera (V4L or GPhoto2 API).

Options:
  -h, --help                           Displays this help.
  -v, --version                        Displays version information.
  -o, --output <directory>             Output directory.
  -V, --verbose                        Verbose output.
  -d, --device <device>                Capture device.
  -l, --list                           List available capture devices and
                                       exits.
  -i, --interval <interval>            Capture interval (in milliseconds).
                                       Default is 10000.
  -c, --count <count>                  How many images should be captured.
                                       Default value is infinite.
  -r, --raw                            Store all captured images in raw.
  -s, --shutterspeed-options           Prints available shutterspeed setting
                                       choices and exits.
  -a, --adaptive-shutterspeed <count>  Camera shutterspeed will be adaptively
                                       changed after exposure metering.
                                       This option setup how many images should
                                       be used for exposure metering. 
                                       Default value is 0 - it means that
                                       shutterspeed will not be changed by
                                       capture tool.
  --shutterspeed-step <step>           How large should be step when changing
                                       shutterspeed. 
                                       Default value is 1.
  --min-shutterspeed <shutterspeed>    Minimum shutterspeed (fastest shutter)
                                       used by adaptive shutterspeed
  --max-shutterspeed <shutterspeed>    Maximum shutterspeed (slowest shutter)
                                       used by adaptive shutterspeed.
                                       If camera supports BULB shutterspeed, it
                                       can be defined as "BULB:XX" here (it
                                       means bulb with XX s exposure).

Detect cameras and choose one for capturing

Program tries auto-detect cameras connected to the system. List of detected cameras can look like this:

$ timelapse_capture --list
Found devices: 
  /dev/video0   "HP HD Webcam [Fixed]" @ usb-0000:00:1a.0-1.3 (uvcvideo 4.4.0)
  usb:003,006   "Nikon DSC D5100 (PTP mode)"

If tool is started without specific device it will use the first one. But if you want to use second device, you have to specify --device option. Device can be specified by any term from identification string, so all following options works:

$ timelapse_capture --device D5100 ...
$ timelapse_capture --device Nikon ...
$ timelapse_capture --device video0 ...
$ timelapse_capture --device HP ...

Adaptive shutter speed

When light conditions are changing during timelapse (sunset, cloudy wheater...) it makes sense to change camera shutter time to avoid underexposured or overexposured images. Alogrithm uses data from previous frames and change shutterspeed smoothly, so it should provide better results for timelapse than automatic exposure setting on camera. This functionality is now supported with some GPhoto2-based cameras. For test if specific camera support shutterspeed setting try --shutterspeed-options:

$ timelapse_capture --device Nikon --shutterspeed-options
Using device usb:003,010        "Nikon DSC D5100 (PTP mode)"
Device Nikon DSC D5100 (PTP mode) shutterspeed choices:
  1/4000
  1/3200
  1/2500
  ...
  20
  25
  30
Current shutter speed: 1/25

$ timelapse_capture --device HP --shutterspeed-options
Using device /dev/video0        "HP HD Webcam [Fixed]" @ usb-0000:00:1a.0-1.3 (uvcvideo 4.4.0)
Device /dev/video0 don't support shutterspeed setting

Automatic shutterspeed is activated by setting --adaptive-shutterspeed option to number greater than 0. Algorithm use last N captured images (count setup by --adaptive-shutterspeed) and if more than N/3 is underexposured (or overexposured) it setup longer shutter (or shorter) by X steps (setup by --shutterspeed-step). Setup shutterspeed is keep in range defined by --min-shutterspeed and --max-shutterspeed.

  • underexposured image is defined that it contains more than 5% of 5% dark pixels (0% is black, 100% white)
  • overexposured image: more than 5% of 95% bright pixels

For details, look into source code :-) - MatrixMeteringAlg::adjustShutterSpeed

For testing, don't forgot turn on verbose output by --verbose.

Clone this wiki locally