- Notifications
You must be signed in to change notification settings - Fork 30
feat: add support for a number of exposure-related options #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| | @@ -239,6 +239,13 @@ const stillCamera = new StillCamera({ | |||||||||||||||||||||||||||||||||||||||||||||
| - [`rotation: Rotation`](#rotation) - *Default: `Rotation.Rotate0`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`flip: Flip`](#flip) - *Default: `Flip.None`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `delay: number` - *Default: 1 ms* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `shutter: number` - *Default: Auto calculated based on framerate (1000000µs/fps). Number is in microseconds* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `iso: number` - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `exposureCompensation: number` - *Default: `0`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`exposureMode: ExposureMode`](#exposuremode) - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`awbMode: AwbMode`](#awbmode) - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `analoggain: number` - *Default: 0* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `digitalgain: number` - *Default: 0* | ||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||
| ### `StillCamera.takeImage(): Promise<Buffer>` | ||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||
| | @@ -271,6 +278,13 @@ const streamCamera = new StreamCamera({ | |||||||||||||||||||||||||||||||||||||||||||||
| - `fps: number` - *Default: 30 fps* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`codec: Codec`](#codec) - *Default: `Codec.H264`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`sensorMode: SensorMode`](#sensormode) - *Default: `SensorMode.AutoSelect`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `shutter: number` - *Default: Auto calculated based on framerate (1000000µs/fps). Number is in microseconds* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `iso: number` - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `exposureCompensation: number` - *Default: `0`* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`exposureMode: ExposureMode`](#exposuremode) - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - [`awbMode: AwbMode`](#awbmode) - *Default: Auto* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `analoggain: number` - *Default: 0* | ||||||||||||||||||||||||||||||||||||||||||||||
| - `digitalgain: number` - *Default: 0* | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
| - `analoggain: number` - *Default: 0* | |
| - `digitalgain: number` - *Default: 0* | |
| - `analogGain: number` - *Default: 0* | |
| - `digitalGain: number` - *Default: 0* |
gregnr marked this conversation as resolved. Show resolved Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `Off` | |
| - `Auto` | |
| - `Sun` | |
| - `Cloud` | |
| - `Shade` | |
| - `Tungsten` | |
| - `Fluorescent` | |
| - `Incandescent` | |
| - `Flash` | |
| - `Horizon` | |
| - `GreyWorld` | |
| - `AwbMode.Off` | |
| - `AwbMode.Auto` | |
| - `AwbMode.Sun` | |
| - `AwbMode.Cloud` | |
| - `AwbMode.Shade` | |
| - `AwbMode.Tungsten` | |
| - `AwbMode.Fluorescent` | |
| - `AwbMode.Incandescent` | |
| - `AwbMode.Flash` | |
| - `AwbMode.Horizon` | |
| - `AwbMode.GreyWorld` |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,81 @@ | ||||||
| import { StillOptions } from "./still-camera"; | ||||||
| import { StreamOptions } from "./stream-camera"; | ||||||
| import { Flip } from '..'; | ||||||
| | ||||||
| /** | ||||||
| * Get the command line arguments for `raspistill` or `raspivid` that are common among both | ||||||
| * | ||||||
| * These are: `--width`, `--height`, `--rotation`, `--hflip`, `--vflip`, `--shutter`, | ||||||
| * `--ISO`, `--exposure`, `--ev`, and `--awb` | ||||||
| * @param options Camera options | ||||||
| */ | ||||||
| export function getSharedArgs(options: StillOptions | StreamOptions): string[] { | ||||||
| return [ | ||||||
| | ||||||
| /** | ||||||
| * Width | ||||||
| */ | ||||||
| ...(options.width ? ['--width', options.width.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Height | ||||||
| */ | ||||||
| ...(options.height ? ['--height', options.height.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Rotation | ||||||
| */ | ||||||
| ...(options.rotation ? ['--rotation', options.rotation.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Horizontal flip | ||||||
| */ | ||||||
| ...(options.flip && | ||||||
| (options.flip === Flip.Horizontal || options.flip === Flip.Both) | ||||||
| ? ['--hflip'] | ||||||
| : []), | ||||||
| | ||||||
| /** | ||||||
| * Vertical flip | ||||||
| */ | ||||||
| ...(options.flip && | ||||||
| (options.flip === Flip.Vertical || options.flip === Flip.Both) | ||||||
| ? ['--vflip'] | ||||||
| : []), | ||||||
| | ||||||
| /** | ||||||
| * Shutter Speed | ||||||
| */ | ||||||
| ...(options.shutter ? ["--shutter", options.shutter.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * ISO | ||||||
| */ | ||||||
| ...(options.iso ? ['--ISO', options.iso.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * EV Compensation | ||||||
| */ | ||||||
| ...(options.exposureCompensation ? ['--ev', options.exposureCompensation.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Exposure Mode | ||||||
| */ | ||||||
| ...(options.exposureMode ? ['--exposure', options.exposureMode.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Auto White Balance Mode | ||||||
| */ | ||||||
| ...(options.awbMode ? ['--awb', options.awbMode.toString()] : []), | ||||||
| | ||||||
| /** | ||||||
| * Analog Gain | ||||||
| */ | ||||||
| ...(options.analoggain ? ['--analoggain', options.analoggain.toString()] : []), | ||||||
| ||||||
| ...(options.analoggain ? ['--analoggain', options.analoggain.toString()] : []), | |
| ...(options.analogGain ? ['--analoggain', options.analogGain.toString()] : []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that was a copy-paste/multi-line edit thing. I'll fix that.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ...(options.digitalgain ? ['--digitalgain', options.digitalgain.toString()] : []) | |
| ...(options.digitalGain ? ['--digitalgain', options.digitalGain.toString()] : []) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,21 @@ | ||||||||||
| import * as si from 'systeminformation'; | ||||||||||
| import { Flip, Rotation } from '..'; | ||||||||||
| import { AwbMode, ExposureMode, Flip, Rotation } from '..'; | ||||||||||
| import { spawnPromise } from '../util'; | ||||||||||
| import { getSharedArgs } from './shared-args'; | ||||||||||
| | ||||||||||
| export interface StillOptions { | ||||||||||
| width?: number; | ||||||||||
| height?: number; | ||||||||||
| rotation?: Rotation; | ||||||||||
| flip?: Flip; | ||||||||||
| delay?: number; | ||||||||||
| shutter?: number; | ||||||||||
| iso?: number; | ||||||||||
| exposureCompensation?: number; | ||||||||||
| exposureMode?: ExposureMode; | ||||||||||
| awbMode?: AwbMode; | ||||||||||
| analoggain?: number; | ||||||||||
| digitalgain?: number; | ||||||||||
| ||||||||||
| analoggain?: number; | |
| digitalgain?: number; | |
| analogGain?: number; | |
| digitalGain?: number; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| | @@ -2,7 +2,8 @@ import { ChildProcessWithoutNullStreams, spawn } from 'child_process'; | |||||||||
| import { EventEmitter } from 'events'; | ||||||||||
| import * as stream from 'stream'; | ||||||||||
| import * as si from 'systeminformation'; | ||||||||||
| import { Flip, Rotation } from '..'; | ||||||||||
| import { AwbMode, ExposureMode, Flip, Rotation } from '..'; | ||||||||||
| import { getSharedArgs } from './shared-args'; | ||||||||||
| | ||||||||||
| export enum Codec { | ||||||||||
| H264 = 'H264', | ||||||||||
| | @@ -29,6 +30,13 @@ export interface StreamOptions { | |||||||||
| fps?: number; | ||||||||||
| codec?: Codec; | ||||||||||
| sensorMode?: SensorMode; | ||||||||||
| shutter?: number; | ||||||||||
| iso?: number; | ||||||||||
| exposureCompensation?: number; | ||||||||||
| exposureMode?: ExposureMode; | ||||||||||
| awbMode?: AwbMode; | ||||||||||
| analoggain?: number; | ||||||||||
| digitalgain?: number; | ||||||||||
| ||||||||||
| analoggain?: number; | |
| digitalgain?: number; | |
| analogGain?: number; | |
| digitalGain?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.