-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathshared-args.ts
More file actions
119 lines (99 loc) · 2.86 KB
/
shared-args.ts
File metadata and controls
119 lines (99 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { StillOptions } from './still-camera';
import { StreamOptions } from './stream-camera';
import { Flip } from '..';
/**
* Generates the annotate command line arguments
*
* @param annotate Annotate option array
*/
function generateAnnotate(annotate: (number | string)[]): string[] {
const argumentsArray: string[] = [];
for (const element of annotate) {
argumentsArray.push('--annotate');
argumentsArray.push(typeof element === 'number' ? element.toString() : element);
}
return argumentsArray;
}
/**
* Get the command line arguments for `raspistill` or `raspivid` that are common among both
*
* @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()] : []),
/**
* Sharpness (-100 to 100; default 0)
*/
...(options.sharpness ? ['--sharpness', options.sharpness.toString()] : []),
/**
* Contrast (-100 to 100; default 0)
*/
...(options.contrast ? ['--contrast', options.contrast.toString()] : []),
/**
* Brightness (0 to 100; default 50)
*/
...(options.brightness || options.brightness === 0
? ['--brightness', options.brightness.toString()]
: []),
/**
* Saturation (-100 to 100; default 0)
*/
...(options.saturation ? ['--saturation', options.saturation.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()] : []),
/**
* Digital Gain
*/
...(options.digitalGain ? ['--digitalgain', options.digitalGain.toString()] : []),
/**
* Annotate
*/
...(options.annotate ? generateAnnotate(options.annotate) : []),
];
}