node-libcamera 0.1.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # node-libcamera 📷
2
2
 
3
+ ![npm](https://img.shields.io/npm/v/node-libcamera)
4
+ ![npm bundle size](https://img.shields.io/bundlephobia/min/node-libcamera)
5
+ ![node-current](https://img.shields.io/node/v/node-libcamera)
6
+ ![NPM](https://img.shields.io/npm/l/node-libcamera)
7
+ ![checks](https://badgen.net/github/checks/superhussain/node-libcamera)
8
+
3
9
  A set of wrapper functions for the native [Raspberry Pi `libcamera` API](https://www.raspberrypi.com/documentation/accessories/camera.html).
4
10
 
5
11
  _Open to any and all contributions!_
@@ -17,15 +23,15 @@ npm install node-libcamera
17
23
  Capture an image!
18
24
 
19
25
  ```js
20
- const { still } = require('node-libcamera')
26
+ const libcamera = require('node-libcamera')
21
27
 
22
28
  // basic example
23
- still({ output: 'test.jpg' })
29
+ libcamera.still({ output: 'test.jpg' })
24
30
  .then((result) => /* 📸 */ )
25
31
  .catch((error) => /* 🐛 */ )
26
32
 
27
33
  // example with options
28
- still({
34
+ libcamera.still({
29
35
  output: 'images/test.jpg', // output file path
30
36
  timeout: 2000, // timeout before taking the picture
31
37
  width: 640, // image width
@@ -40,10 +46,10 @@ still({
40
46
  Record a video!
41
47
 
42
48
  ```js
43
- const { vid } = require('node-libcamera')
49
+ const libcamera = require('node-libcamera')
44
50
 
45
51
  // record a 10s video
46
- vid({ output: 'test.h264', timeout: 10000, 'save-pts': 'timestamps.txt' })
52
+ libcamera.vid({ output: 'test.h264', timeout: 10000, 'save-pts': 'timestamps.txt' })
47
53
  .then((result) => /* 🎥 */ )
48
54
  .catch((error) => /* 🐛 */ )
49
55
  ```
@@ -0,0 +1,587 @@
1
+ export declare namespace LibCamera {
2
+ interface CommandLineOptions {
3
+ /**
4
+ * Print help information for the application
5
+ *
6
+ * The `--help` option causes every application to print its full set of command line options with a brief synopsis of each, and then quit.
7
+ **/
8
+ help: boolean;
9
+ /**
10
+ * Print out a software version number
11
+ *
12
+ * All `libcamera-apps` will, when they see the `--version` option, print out a version string both for `libcamera` and `libcamera-apps` and then quit.
13
+ */
14
+ version: boolean;
15
+ /**
16
+ * Delay before application stops automatically <milliseconds>
17
+ *
18
+ * The `--timeout` option specifies how long the application runs before it stops, whether it is recording a video or showing a preview. In the case of still image capture, the application will show the preview window for this long before capturing the output image.
19
+ *
20
+ * If unspecified, the default value is 5000 (5 seconds). The value zero causes the application to run indefinitely.
21
+ */
22
+ timeout: number;
23
+ }
24
+ interface PreviewWindowOptions {
25
+ /**
26
+ * Preview window settings
27
+ *
28
+ * Sets the size and location of the preview window (both X Windows and DRM versions). It does not affect the resolution or aspect ratio of images being requested from the camera. The camera images will be scaled to the size of the preview window for display, and will be pillar/letter-boxed to fit.
29
+ *
30
+ * Example:
31
+ * ```json
32
+ * { "x": 100, "y": 100, "width": 500, "height": 500 }
33
+ * ```
34
+ */
35
+ preview: PreviewOption;
36
+ /**
37
+ * Fullscreen preview mode
38
+ *
39
+ * Forces the preview window to use the whole screen, and the window will have no border or title bar. Again the image may be pillar/letter-boxed.
40
+ */
41
+ fullscreen: boolean;
42
+ /**
43
+ * Use Qt-based preview window
44
+ *
45
+ * The preview window is switched to use the Qt-based implementation. This option is not normally recommended because it no longer uses zero-copy buffer sharing nor GPU acceleration and is therefore very expensive, however, it does support X forwarding (which the other preview implementations do not).
46
+ *
47
+ * The Qt preview window does not support the `--fullscreen` option. Generally it is advised to try and keep the preview window small.
48
+ */
49
+ 'qt-preview': boolean;
50
+ /**
51
+ * Do not display a preview window
52
+ *
53
+ * The preview window is suppressed entirely.
54
+ */
55
+ nopreview: boolean;
56
+ /**
57
+ * Set window title bar text <string>
58
+ *
59
+ * The supplied string is set as the title of the preview window (when running under X Windows). Additionally the string may contain a number of `%` directives which are substituted with information from the image metadata. The permitted directives are:
60
+ *
61
+ * | Directive | Substitution |
62
+ * | :--------------- | :------------------ |
63
+ * | `%frame` | The sequence number of the frame |
64
+ * | `%fps` | The instantaneous frame rate |
65
+ * | `%exp` | The shutter speed used to capture the image, in microseconds |
66
+ * | `%ag` | The analogue gain applied to the image in the sensor |
67
+ * | `%dg` | The digital gain applied to the image by the ISP |
68
+ * | `%rg` | The gain applied to the red component of each pixel |
69
+ * | `%bg` | The gain applied to the blue component of each pixel |
70
+ * | `%focus` | The focus metric for the image, where a larger value implies a sharper image |
71
+ *
72
+ * When not provided, the `--info-text` string defaults to `"#%frame (%fps fps) exp %exp ag %ag dg %dg"`.
73
+ */
74
+ 'info-text': string;
75
+ }
76
+ interface CameraResolutionOptions {
77
+ /**
78
+ * Capture image width <width>
79
+ *
80
+ * This number specifies the output resolution of the camera images captured by libcamera-still, libcamera-jpeg and libcamera-vid.
81
+ *
82
+ * For libcamera-raw, it affects the size of the raw frames captured. Where a camera has a 2x2 binned readout mode, specifying a resolution not larger than this binned mode will result in the capture of 2x2 binned raw frames.
83
+ *
84
+ * For libcamera-hello these parameters have no effect.
85
+ */
86
+ width: number;
87
+ /**
88
+ * Capture image height <height>
89
+ *
90
+ * This number specifies the output resolution of the camera images captured by libcamera-still, libcamera-jpeg and libcamera-vid.
91
+ *
92
+ * For libcamera-raw, it affects the size of the raw frames captured. Where a camera has a 2x2 binned readout mode, specifying a resolution not larger than this binned mode will result in the capture of 2x2 binned raw frames.
93
+ *
94
+ * For libcamera-hello these parameters have no effect.
95
+ */
96
+ height: number;
97
+ /**
98
+ * Capture image width <width>
99
+ *
100
+ * These options affect only the preview and specify the image size that will be requested from the camera for the preview window. They have no effect on captured still images or videos. Nor do they affect the preview window as the images are resized to fit.
101
+ */
102
+ 'viewfinder-width': number;
103
+ /**
104
+ * Capture image height <height>
105
+ *
106
+ * These options affect only the preview and specify the image size that will be requested from the camera for the preview window. They have no effect on captured still images or videos. Nor do they affect the preview window as the images are resized to fit.
107
+ */
108
+ 'viewfinder-height': number;
109
+ /**
110
+ * Force sensor to capture in full resolution mode
111
+ *
112
+ * This option forces the sensor to be driven in its full resolution readout mode for still and video capture, irrespective of the requested output resolution (given by `--width` and `--height`).
113
+ *
114
+ * Using this option often incurs a frame rate penalty, as larger resolution frames are slower to read out.
115
+ *
116
+ * Example:
117
+ * ```bash
118
+ * libcamera-raw -t 2000 --segment 1 --rawfull -o test%03d.raw
119
+ * ```
120
+ * will cause multiple full resolution raw frames to be captured. On the HQ camera each frame will be about 18MB in size. Without the `rawfull` option the default video output resolution would have caused the 2x2 binned mode to be selected, resulting in 4.5MB raw frames.
121
+ */
122
+ rawfull: boolean;
123
+ /**
124
+ * Low resolution image width <width>
125
+ *
126
+ * `libcamera` allows the possibiliy of delivering a second lower resolution image stream from the the camera system to the application. This stream is available in both the preview and the video modes (i.e. `libcamera-hello` and the preview phase of `libcamera-still`, and `libcamera-vid`), and can be used, among other things, for image analysis. For still captures, the low resolution image stream is not available.
127
+ *
128
+ * The low resolution stream has the same field of view as the other image streams. If a different aspect ratio is specified for the low resolution stream, then those images will be squashed so that the pixels are no longer square.
129
+ *
130
+ * During video recording (`libcamera-vid`), specifying a low resolution stream will disable some extra colour denoise processing that would normally occur.
131
+ */
132
+ 'lores-width': number;
133
+ /**
134
+ * Low resolution image height <height>
135
+ *
136
+ * `libcamera` allows the possibiliy of delivering a second lower resolution image stream from the the camera system to the application. This stream is available in both the preview and the video modes (i.e. `libcamera-hello` and the preview phase of `libcamera-still`, and `libcamera-vid`), and can be used, among other things, for image analysis. For still captures, the low resolution image stream is not available.
137
+ *
138
+ * The low resolution stream has the same field of view as the other image streams. If a different aspect ratio is specified for the low resolution stream, then those images will be squashed so that the pixels are no longer square.
139
+ *
140
+ * During video recording (`libcamera-vid`), specifying a low resolution stream will disable some extra colour denoise processing that would normally occur.
141
+ */
142
+ 'lores-height': number;
143
+ /**
144
+ * Read out with horizontal mirror
145
+ */
146
+ hflip: boolean;
147
+ /**
148
+ * Read out with vertical flip
149
+ */
150
+ vflip: boolean;
151
+ /**
152
+ * Use hflip and vflip to create the given rotation <angle>
153
+ */
154
+ rotation: 0 | 180;
155
+ /**
156
+ * Select a crop (region of interest) from the camera <x,y,w,h>
157
+ *
158
+ * The `roi` (region of interest) option allows the user to select a particular crop from the full field of view provided by the sensor. The coordinates are specified as a proportion of the available field of view, so that `roi: { x: 0, y: 0, w: 1, h: 1 }` would have no effect at all.
159
+ *
160
+ * The `roi` parameter implements what is commonly referred to as "digital zoom".
161
+ *
162
+ * Example `roi: { x: 0.25, y: 0.25, w: 0.5, h: 0.5 }` will select exactly a quarter of the total number of pixels cropped from the centre of the image.
163
+ */
164
+ roi: ROIOption;
165
+ }
166
+ interface CameraControlOptions {
167
+ /**
168
+ * Set image sharpness <number>
169
+ *
170
+ * The given `<number>` adjusts the image sharpness. The value zero means that no sharpening is applied, the value 1.0 uses the default amount of sharpening, and values greater than 1.0 use extra sharpening.
171
+ */
172
+ sharpness: number;
173
+ /**
174
+ * Set image contrast <number>
175
+ *
176
+ * The given `<number>` adjusts the image contrast. The value zero produces minimum contrast, the value 1.0 uses the default amount of contrast, and values greater than 1.0 apply extra contrast.
177
+ */
178
+ contrast: number;
179
+ /**
180
+ * Set image brightness <number>
181
+ *
182
+ * The given `<number>` adjusts the image brightness. The value -1.0 produces an (almost) black image, the value 1.0 produces an almost entirely white image and the value 0.0 produces standard image brightness.
183
+ *
184
+ * Note that the brightness parameter adds (or subtracts) an offset from all pixels in the output image. The `ev` option is often more appropriate.
185
+ */
186
+ brightness: number;
187
+ /**
188
+ * Set image colour saturation <number>
189
+ *
190
+ * The given `<number>` adjusts the colour saturation. The value zero produces a greyscale image, the value 1.0 uses the default amount of sautration, and values greater than 1.0 apply extra colour saturation.
191
+ */
192
+ saturation: number;
193
+ /**
194
+ * Set EV compensation <number>
195
+ *
196
+ * Sets the EV compensation of the image in units of stops, in the range -10 to 10. Default is 0. It works by raising or lowering the target values the AEC/AGC algorithm is attempting to match.
197
+ */
198
+ ev: number;
199
+ /**
200
+ * Set the exposure time in microseconds <number>
201
+ *
202
+ * The shutter time is fixed to the given value. The gain will still be allowed to vary (unless that is also fixed).
203
+ *
204
+ * Note that this shutter time may not be achieved if the camera is running at a frame rate that is too fast to allow it. In this case the `framerate` option may be used to lower the frame rate. The maximum possible shutter times for the official Raspberry Pi supported can be found in this table.
205
+ *
206
+ * Using values above these maximums will result in undefined behaviour. Cameras will also have different minimum shutter times, though in practice this is not important as they are all low enough to expose bright scenes appropriately.
207
+ */
208
+ shutter: number;
209
+ /**
210
+ * Sets the combined analogue and digital gains <number>
211
+ *
212
+ * Where the requested gain can be supplied by the sensor driver, then only analogue gain will be used. Once the analogue gain reaches the maximum permitted value, then extra gain beyond this will be supplied as digital gain.
213
+ *
214
+ * Note that there are circumstances where the digital gain can go above 1 even when the analogue gain limit is not exceeded. This can occur when
215
+ *
216
+ * * Either of the colour gains goes below 1.0, which will cause the digital gain to settle to 1.0/min(red_gain,blue_gain). This means that the total digital gain being applied to any colour channel does not go below 1.0, as that would cause discolouration artifacts.
217
+ *
218
+ * * The digital gain can vary slightly while the AEC/AGC changes, though this effect should be only transient.
219
+ */
220
+ gain: number;
221
+ /**
222
+ * Sets the combined analogue and digital gains <number>
223
+ *
224
+ * Where the requested gain can be supplied by the sensor driver, then only analogue gain will be used. Once the analogue gain reaches the maximum permitted value, then extra gain beyond this will be supplied as digital gain.
225
+ *
226
+ * Note that there are circumstances where the digital gain can go above 1 even when the analogue gain limit is not exceeded. This can occur when
227
+ *
228
+ * * Either of the colour gains goes below 1.0, which will cause the digital gain to settle to 1.0/min(red_gain,blue_gain). This means that the total digital gain being applied to any colour channel does not go below 1.0, as that would cause discolouration artifacts.
229
+ *
230
+ * * The digital gain can vary slightly while the AEC/AGC changes, though this effect should be only transient.
231
+ */
232
+ analoggain: number;
233
+ /**
234
+ * Set the metering mode <string>
235
+ *
236
+ * Sets the metering mode of the AEC/AGC algorithm. This may one of the following values
237
+ *
238
+ * * `centre` - centre weighted metering (which is the default)
239
+ * * `spot` - spot metering
240
+ * * `average` - average or whole frame metering
241
+ * * `custom` - custom metering mode which would have to be defined in the camera tuning file.
242
+ *
243
+ * For more information on defining a custom metering mode, and also on how to adjust the region weights in the existing metering modes, please refer to the [Tuning guide for the Raspberry Pi cameras and libcamera](https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf).
244
+ */
245
+ metering: 'centre' | 'spot' | 'average' | 'custom';
246
+ /**
247
+ * Set the exposure profile <string>
248
+ *
249
+ * The exposure profile may be either `normal` or `sport`. Changing the exposure profile should not affect the overall exposure of an image, but the `sport` mode will tend to prefer shorter exposure times and larger gains to achieve the same net result.
250
+ *
251
+ * Exposure profiles can be edited in the camera tuning file. Please refer to the [Tuning guide for the Raspberry Pi cameras and libcamera](https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf) for more information.
252
+ */
253
+ exposure: 'normal' | 'sport';
254
+ /**
255
+ * Set the AWB mode <string>
256
+ *
257
+ * This option sets the AWB algorithm into the named AWB mode. Valid modes are:
258
+ *
259
+ * | Mode name | Colour temperature |
260
+ * | :--------------- | :------------------ |
261
+ * | `auto` | 2500K to 8000K |
262
+ * | `incandescent` | 2500K to 3000K |
263
+ * | `tungsten` | 3000K to 3500K |
264
+ * | `fluorescent` | 4000K to 4700K |
265
+ * | `indoor` | 3000K to 5000K |
266
+ * | `daylight` | 5500K to 6500K |
267
+ * | `cloudy` | 7000K to 8500K |
268
+ * | `custom` | A custom range would have to be defined in the camera tuning file. |
269
+ *
270
+ * There is no mode that turns the AWB off, instead fixed colour gains should be specified with the `awbgains` option.
271
+ *
272
+ * Note that these values are only approximate, the values could vary according to the camera tuning.
273
+ *
274
+ * For more information on AWB modes and how to define a custom one, please refer to the Tuning guide for the Raspberry Pi cameras and libcamera.
275
+ */
276
+ awb: string;
277
+ /**
278
+ * Set fixed colour gains <number,number>
279
+ *
280
+ * This option accepts a red and a blue gain value and uses them directly in place of running the AWB algorithm. Setting non-zero values here has the effect of disabling the AWB calculation.
281
+ */
282
+ awbgains: [number, number];
283
+ /**
284
+ * Set the denoising mode <string>
285
+ *
286
+ * The following denoise modes are supported:
287
+ * * `auto` - This is the default. It always enables standard spatial denoise. It uses extra fast colour denoise for video, and high quality colour denoise for stills capture. Preview does not enable any extra colour denoise at all.
288
+ * * `off` - Disables spatial and colour denoise.
289
+ * * `cdn_off` - Disables colour denoise.
290
+ * * `cdn_fast` - Uses fast color denoise.
291
+ * * `cdn_hq` - Uses high quality colour denoise. Not appropriate for video/viewfinder due to reduced throughput.
292
+ *
293
+ * Note that even the use of fast colour denoise can result in lower framerates. The high quality colour denoise will normally result in much lower framerates.
294
+ */
295
+ denoise: 'auto' | 'off' | 'cdn_off' | 'cdn_fast' | 'cdn_hq';
296
+ /**
297
+ * Specify the camera tuning to use <string>
298
+ *
299
+ * This identifies the name of the JSON format tuning file that should be used. The tuning file covers many aspects of the image processing, including the AEC/AGC, AWB, colour shading correction, colour processing, denoising and so forth.
300
+ *
301
+ * For more information on the camera tuning file, please consult the [Tuning guide for the Raspberry Pi cameras and libcamera](https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf).
302
+ */
303
+ 'tuning-file': string;
304
+ }
305
+ interface OutputFileOptions {
306
+ /**
307
+ * Output file name <string>
308
+ *
309
+ * `--output` sets the name of the output file to which the output image or video is written. Besides regular file names, this may take the following special values:
310
+ *
311
+ * * `-` - write to stdout
312
+ *
313
+ * * `udp://` - a string starting with this is taken as a network address for streaming
314
+ *
315
+ * * `tcp://` - a string starting with this is taken as a network address for streaming
316
+ *
317
+ * * a string containing a `%d` directive is taken as a file name where the format directive is replaced with a count that increments for each file that is opened. Standard C format directive modifiers are permitted.
318
+ */
319
+ output: string;
320
+ /**
321
+ * Wrap output file counter at <number>
322
+ *
323
+ * When outputting to files with an incrementing counter (e.g. `%d` in the output file name), wrap the counter back to zero when it reaches this value.
324
+ */
325
+ wrap: number;
326
+ /**
327
+ * Flush output files immediately
328
+ *
329
+ * `flush` causes output files to be flushed to disk as soon as every frame is written, rather than waiting for the system to do it.
330
+ */
331
+ flush: boolean;
332
+ }
333
+ interface PostProcessingOptions {
334
+ /**
335
+ * The `post-process-file` option specifies a JSON file that configures the post-processing that the imaging pipeline applies to camera images before they reach the application. It can be thought of as a replacement for the legacy raspicam "image effects".
336
+ *
337
+ * Post-processing is a large topic and admits the use of 3rd party software like OpenCV and TensorFlowLite to analyse and manipulate images. For more information, please refer to the section on [post-processing](https://www.raspberrypi.com/documentation/accessories/camera.html#post-processing).
338
+ */
339
+ 'post-process-file': string;
340
+ }
341
+ interface StillOptions {
342
+ /**
343
+ * JPEG quality <number>
344
+ *
345
+ * Set the JPEG quality. 100 is maximum quality and 93 is the default. Only applies when saving JPEG files.
346
+ */
347
+ quality: number;
348
+ /**
349
+ * Add extra EXIF tags <string>
350
+ *
351
+ * The given extra EXIF tags are saved in the JPEG file. Only applies when saving JPEG files.
352
+ *
353
+ * EXIF is supported using the `libexif` library and so there are some associated limitations. In particular, `libexif` seems to recognise a number of tags but without knowing the correct format for them. The software will currently treat these (incorrectly, in many cases) as ASCII, but will print a warning to the terminal. As we come across these they can be added to the table of known exceptions in the software.
354
+ *
355
+ * Clearly the application needs to supply EXIF tags that contain specific camera data (like the exposure time). But for other tags that have nothing to do with the camera, a reasonable workaround would simply be to add them post facto, using something like `exiftool`.
356
+ */
357
+ exif: string;
358
+ /**
359
+ * Time interval between timelapse captures <milliseconds>
360
+ *
361
+ * This puts `libcamera-still` into timelapse mode where it runs according to the timeout (`timeout`) that has been set, and for that period will capture repeated images at the interval specified here. (`libcamera-still` only.)
362
+ */
363
+ timelapse: number;
364
+ /**
365
+ * The starting value for the frame counter <number>
366
+ *
367
+ * When writing counter values into the output file name, this specifies the starting value for the counter.
368
+ *
369
+ * Example:
370
+ * ```bash
371
+ * libcamera-still -t 100000 -o test%d.jpg --timelapse 10000 --framestart 1
372
+ * ```
373
+ * captures an image every 10s for about 100s, starting at 1 rather than 0. (`libcamera-still` only.)
374
+ */
375
+ framestart: number;
376
+ /**
377
+ * Use date format for the output file names
378
+ *
379
+ * Use the current date and time to construct the output file name, in the form MMDDhhmmss.jpg, where MM = 2-digit month number, DD = 2-digit day number, hh = 2-digit 24-hour hour number, mm = 2-digit minute number, ss = 2-digit second number. (`libcamera-still` only.)
380
+ */
381
+ datetime: boolean;
382
+ /**
383
+ * Use system timestamps for the output file names
384
+ *
385
+ * Uses the current system timestamp (the number of seconds since the start of 1970) as the the output file name. (`libcamera-still` only.)
386
+ */
387
+ timestamp: boolean;
388
+ /**
389
+ * Set the JPEG restart interval <number>
390
+ *
391
+ * Sets the JPEG restart interval to the given value. Default is zero.
392
+ */
393
+ restart: number;
394
+ /**
395
+ * Capture image when Enter pressed
396
+ *
397
+ * This switches `libcamera-still` into keypress mode. It will capture a still image either when the timeout expires or the Enter key is pressed in the terminal window. Typing x and Enter causes `libcamera-still` to quit without capturing.
398
+ */
399
+ keypress: boolean;
400
+ /**
401
+ * Capture image when SIGUSR1 received
402
+ *
403
+ * This switches `libcamera-still` into signal mode. It will capture a still image either when the timeout expires or a SIGUSR1 is received. SIGUSR2 will cause `libcamera-still` to quit without capturing.
404
+ *
405
+ * Example:
406
+ *
407
+ * ```bash
408
+ * libcamera-still -t 0 -o test.jpg -s &
409
+ * ```
410
+ *
411
+ * then
412
+ *
413
+ * ```bash
414
+ * kill -SIGUSR1 $!
415
+ * ```
416
+ */
417
+ signal: boolean;
418
+ /**
419
+ * Set thumbnail parameters <w:h:q>
420
+ *
421
+ * Sets the dimensions and quality parameter of the associated thumbnail image. The defaults are size 320x240 and quality 70.
422
+ */
423
+ thumb: ThumbOption;
424
+ /**
425
+ * Set the still image codec <string>
426
+ *
427
+ * Select the still image encoding to be used. Valid encoders are:
428
+ * * `jpg` - JPEG (the default)
429
+ * * `png` - PNG format
430
+ * * `bmp` - BMP format
431
+ * * `rgb` - binary dump of uncompressed RGB pixels
432
+ * * `yuv420` - binary dump of uncompressed YUV420 pixels.
433
+ *
434
+ * Note that this option determines the encoding and that the extension of the output file name is ignored for this purpose. However, for the `datetime` and `timestamp` options, the file extension is taken from the encoder name listed above. (`libcamera-still` only.)
435
+ */
436
+ encoding: 'jpg' | 'png' | 'bmp' | 'rgb' | 'yuv420';
437
+ /**
438
+ * Save raw file
439
+ *
440
+ * Save a raw Bayer file in DNG format alongside the usual output image. The file name is given by replacing the output file name extension by `.dng`. These are standard DNG files, and can be processed with standard tools like dcraw or RawTherapee, among others. (`libcamera-still` only.)
441
+ *
442
+ * The image data in the raw file is exactly what came out of the sensor, with no processing whatsoever either by the ISP or anything else. The EXIF data saved in the file, among other things, includes:
443
+ * * exposure time
444
+ * * analogue gain (the ISO tag is 100 times the analogue gain used)
445
+ * * white balance gains (which are the reciprocals of the "as shot neutral" values)
446
+ * * the colour matrix used by the ISP.
447
+ */
448
+ raw: boolean;
449
+ /**
450
+ * Make symbolic link to latest file saved <string>
451
+ *
452
+ * This causes `libcamera-still` to make a symbolic link to the most recently saved file, thereby making it easier to identify. (`libcamera-still` only.)
453
+ */
454
+ latest: string;
455
+ }
456
+ interface VideoOptions {
457
+ /**
458
+ * JPEG quality <number>
459
+ *
460
+ * Set the JPEG quality. 100 is maximum quality and 50 is the default. Only applies when saving in MJPEG format.
461
+ */
462
+ quality: number;
463
+ /**
464
+ * H.264 bitrate <number>
465
+ *
466
+ * Set the target bitrate for the H.264 encoder, in bits per second. Only applies when encoding in H.264 format.
467
+ */
468
+ bitrate: number;
469
+ /**
470
+ * Intra-frame period (H.264 only) <number>
471
+ *
472
+ * Sets the frequency of I (Intra) frames in the H.264 bitstream, as a number of frames. The default value is 60.
473
+ */
474
+ intra: number;
475
+ /**
476
+ * H.264 profile <string>
477
+ *
478
+ * Set the H.264 profile. The value may be `baseline`, `main` or `high`.
479
+ */
480
+ profile: 'baseline' | 'main' | 'high';
481
+ /**
482
+ * H.264 level <string>
483
+ *
484
+ * Set the H.264 level. The value may be 4, 4.1 or 4.2.
485
+ */
486
+ level: '4' | '4.1' | '4.2';
487
+ /**
488
+ * Encoder to be used <string>
489
+ *
490
+ * This can select how the video frames are encoded. Valid options are:
491
+ * * `h264` - use H.264 encoder (the default)
492
+ * * `mjpeg` - use MJPEG encoder
493
+ * * `yuv420` - output uncompressed YUV420 frames.
494
+ */
495
+ codec: 'h264' | 'mjpeg' | 'yuv420';
496
+ /**
497
+ * Toggle between recording and pausing
498
+ *
499
+ * Pressing Enter will toggle `libcamera-vid` between recording the video stream and not recording it (i.e. discarding it). The application starts off in the recording state, unless the `initial` option specifies otherwise. Typing `x` and Enter causes `libcamera-vid` to quit.
500
+ */
501
+ keypress: boolean;
502
+ /**
503
+ * Toggle between recording and pausing when SIGUSR1 received
504
+ *
505
+ * The SIGUSR1 signal will toggle `libcamera-vid` between recording the video stream and not recording it (i.e. discarding it). The application starts off in the recording state, unless the `initial` option specifies otherwise. SIGUSR2 causes `libcamera-vid` to quit.
506
+ *
507
+ * Example:
508
+ *
509
+ * ```bash
510
+ * libcamera-vid -t 0 -o test.h264 -s
511
+ * ```
512
+ *
513
+ * then
514
+ *
515
+ * ```bash
516
+ * kill -SIGUSR1 $!
517
+ * ```
518
+ */
519
+ signal: boolean;
520
+ /**
521
+ * Start the application in the recording or paused state <string>
522
+ *
523
+ * The value passed may be `record` or `pause` to start the application in, respectively, the recording or the paused state. This option should be used in conjunction with either `keypress` or `signal` to toggle between the two states.
524
+ */
525
+ initial: 'record' | 'pause';
526
+ /**
527
+ * Split multiple recordings into separate files
528
+ *
529
+ * This option should be used in conjunction with `keypress` or `signal` and causes each recording session (inbetween the pauses) to be written to a separate file.
530
+ */
531
+ split: boolean;
532
+ /**
533
+ * Write the video recording into multiple segments <number>
534
+ *
535
+ * This option causes the video recording to be split accross multiple files where the parameter gives the approximate duration of each file in milliseconds.
536
+ *
537
+ * One convenient little trick is to pass a very small duration parameter (namely, `segment: 1`) which will result in each frame being written to a separate output file. This makes it easy to do "burst" JPEG capture (using the MJPEG codec), or "burst" raw frame capture (using `libcamera-raw`).
538
+ */
539
+ segment: number;
540
+ /**
541
+ * Write the video recording into a circular buffer.
542
+ *
543
+ * The video recording is written to a circular buffer which is written to disk when the application quits. The size of the circular buffer is 4MB.
544
+ */
545
+ circular: boolean;
546
+ /**
547
+ * Write sequence header in every I frame (H.264 only)
548
+ *
549
+ * This option causes the H.264 sequence headers to be written into every I (Intra) frame. This is helpful because it means a client can understand and decode the video sequence from any I frame, not just from the very beginning of the stream. It is recommended to use this option with any output type that breaks the output into pieces (`segment`, `split`, `circular`), or transmits the output over a network.
550
+ */
551
+ inline: boolean;
552
+ /**
553
+ * Wait for an incoming TCP connection
554
+ *
555
+ * This option is provided for streaming over a network using TCP/IP. Using `listen` will cause `libcamera-vid` to wait for an incoming client connection before starting the video encode process, which will then be forwarded to that client.
556
+ */
557
+ listen: boolean;
558
+ /**
559
+ * Saves timestamp information to the specified file. Useful as an input file to `mkvmerge`.
560
+ */
561
+ 'save-pts': string;
562
+ }
563
+ type BaseOptions = CommandLineOptions & PreviewWindowOptions & CameraResolutionOptions & CameraControlOptions & OutputFileOptions & PostProcessingOptions;
564
+ type StillOptionsObject = BaseOptions & StillOptions;
565
+ type VideoOptionsObject = BaseOptions & VideoOptions;
566
+ type OptionsObject = BaseOptions & StillOptions & VideoOptions;
567
+ type OptionKeys = keyof OptionsObject;
568
+ type OptionConverter = (val: any) => string;
569
+ interface PreviewOption {
570
+ x: number;
571
+ y: number;
572
+ width: number;
573
+ height: number;
574
+ }
575
+ interface ThumbOption {
576
+ width: number;
577
+ height: number;
578
+ quality: number;
579
+ }
580
+ interface ROIOption {
581
+ x: number;
582
+ y: number;
583
+ w: number;
584
+ h: number;
585
+ }
586
+ }
587
+ export default LibCamera;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { LibCamera } from './options';
2
- export declare function jpeg(options: Partial<LibCamera.OptionsObject>): Promise<unknown>;
3
- export declare function still(options: Partial<LibCamera.OptionsObject>): Promise<unknown>;
4
- export declare function vid(options: Partial<LibCamera.OptionsObject>): Promise<unknown>;
1
+ import LibCamera from './LibCamera';
2
+ export declare function jpeg(options: Partial<LibCamera.StillOptionsObject>): Promise<string>;
3
+ export declare function still(options: Partial<LibCamera.StillOptionsObject>): Promise<string>;
4
+ export declare function vid(options: Partial<LibCamera.VideoOptionsObject>): Promise<string>;
5
+ export declare function raw(options: Partial<LibCamera.VideoOptionsObject>): Promise<string>;
6
+ export declare const libcamera: {
7
+ jpeg: typeof jpeg;
8
+ still: typeof still;
9
+ vid: typeof vid;
10
+ raw: typeof raw;
11
+ };
12
+ export default libcamera;