node-libcamera 0.1.0 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -84
- package/dist/index.d.ts +3 -1
- package/dist/node-libcamera.cjs.development.js +841 -93
- package/dist/node-libcamera.cjs.development.js.map +1 -1
- package/dist/node-libcamera.cjs.production.min.js +1 -1
- package/dist/node-libcamera.cjs.production.min.js.map +1 -1
- package/dist/node-libcamera.esm.js +842 -93
- package/dist/node-libcamera.esm.js.map +1 -1
- package/dist/options.d.ts +121 -11
- package/dist/utils.d.ts +1 -1
- package/package.json +8 -3
- package/src/index.ts +21 -2
- package/src/options.ts +132 -96
- package/src/utils.ts +5 -8
package/README.md
CHANGED
@@ -1,103 +1,55 @@
|
|
1
|
-
#
|
1
|
+
# node-libcamera 📷
|
2
2
|
|
3
|
-
|
3
|
+
A set of wrapper functions for the native [Raspberry Pi `libcamera` API](https://www.raspberrypi.com/documentation/accessories/camera.html).
|
4
4
|
|
5
|
-
|
5
|
+
_Open to any and all contributions!_
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## Commands
|
10
|
-
|
11
|
-
TSDX scaffolds your new library inside `/src`.
|
12
|
-
|
13
|
-
To run TSDX, use:
|
7
|
+
## Installation
|
14
8
|
|
15
9
|
```bash
|
16
|
-
npm
|
10
|
+
npm install node-libcamera
|
17
11
|
```
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
To do a one-off build, use `npm run build` or `yarn build`.
|
22
|
-
|
23
|
-
To run tests, use `npm test` or `yarn test`.
|
24
|
-
|
25
|
-
## Configuration
|
26
|
-
|
27
|
-
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
28
|
-
|
29
|
-
### Jest
|
13
|
+
## Usage
|
30
14
|
|
31
|
-
|
15
|
+
### [`libcamera-still`](https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-still)
|
32
16
|
|
33
|
-
|
17
|
+
Capture an image!
|
34
18
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
```js
|
20
|
+
const { still } = require('node-libcamera')
|
21
|
+
|
22
|
+
// basic example
|
23
|
+
still({ output: 'test.jpg' })
|
24
|
+
.then((result) => /* 📸 */ )
|
25
|
+
.catch((error) => /* 🐛 */ )
|
26
|
+
|
27
|
+
// example with options
|
28
|
+
still({
|
29
|
+
output: 'images/test.jpg', // output file path
|
30
|
+
timeout: 2000, // timeout before taking the picture
|
31
|
+
width: 640, // image width
|
32
|
+
height: 480, // image height
|
33
|
+
})
|
34
|
+
.then((result) => /* 📸 */ )
|
35
|
+
.catch((error) => /* 🐛 */ )
|
50
36
|
```
|
51
37
|
|
52
|
-
###
|
53
|
-
|
54
|
-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
55
|
-
|
56
|
-
### TypeScript
|
57
|
-
|
58
|
-
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
|
59
|
-
|
60
|
-
## Continuous Integration
|
38
|
+
### [`libcamera-vid`](https://www.raspberrypi.com/documentation/accessories/camera.html#libcamera-vid)
|
61
39
|
|
62
|
-
|
63
|
-
|
64
|
-
Two actions are added by default:
|
65
|
-
|
66
|
-
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
67
|
-
- `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
|
68
|
-
|
69
|
-
## Optimizations
|
70
|
-
|
71
|
-
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
40
|
+
Record a video!
|
72
41
|
|
73
42
|
```js
|
74
|
-
|
75
|
-
declare var __DEV__: boolean;
|
43
|
+
const { vid } = require('node-libcamera')
|
76
44
|
|
77
|
-
//
|
78
|
-
|
79
|
-
|
80
|
-
|
45
|
+
// record a 10s video
|
46
|
+
vid({ output: 'test.h264', timeout: 10000, 'save-pts': 'timestamps.txt' })
|
47
|
+
.then((result) => /* 🎥 */ )
|
48
|
+
.catch((error) => /* 🐛 */ )
|
81
49
|
```
|
82
50
|
|
83
|
-
|
84
|
-
|
85
|
-
## Module Formats
|
86
|
-
|
87
|
-
CJS, ESModules, and UMD module formats are supported.
|
88
|
-
|
89
|
-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
90
|
-
|
91
|
-
## Named Exports
|
51
|
+
Note: this will result in an unpackaged video bistream, it is not wrapped in any kind of container format (such as an mp4 file). The `save-pts` option can be used to output frame timestamps so that the bitstream can subsequently be converted into an appropriate format using a tool like `mkvmerge`.
|
92
52
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
98
|
-
|
99
|
-
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
100
|
-
|
101
|
-
## Publishing to NPM
|
102
|
-
|
103
|
-
We recommend using [np](https://github.com/sindresorhus/np).
|
53
|
+
```bash
|
54
|
+
mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264
|
55
|
+
```
|
package/dist/index.d.ts
CHANGED
@@ -1,2 +1,4 @@
|
|
1
1
|
import { LibCamera } from './options';
|
2
|
-
export declare function
|
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>;
|