raspberry-pi-camera-native
v0.0.0
Published
Use your Raspberry Pi Camera Module with Node.js
Downloads
23
Maintainers
Readme
node-raspberry-pi-camera-native
Use your Raspberry Pi Camera Module with Node.js
NOTE: Currently only supports still image capture.
Prerequisites
Hardware
- Raspberry Pi
- Raspberry Pi Camera module
Software
- Raspberry Pi camera enabled
- Node.js 8 or later installed
Install
npm install raspberry-pi-camera-native
Usage
// require module
const raspberryPiCamera = require('raspberry-pi-camera-native');
// add frame data event listener
raspberryPiCamera.on('frame', (frameData) => {
// frameData is a Node.js Buffer
// ...
});
// start capture
raspberryPiCamera.start();
Events
Data
Listen for raw data events (partial frame data), data
is a Node.js Buffer
raspberryPiCamera.on('data', callback(data));
Frame
Listen for frame events (full frame data), frameData
is a Node.js Buffer
raspberryPiCamera.on('frame', callback(frameData));
Actions
Start Capture
raspberryPiCamera.start(options, callback);
Options is a object, with the following defaults:
{
width: 1280,
height: 720,
fps: 30,
encoding: 'JPEG',
quality: 75
}
Supported values:
width
:32
to2592
(v1 camera) or3280
(v2 camera)height
:16
to1944
(v1 camera) or2464
(v2 camera)fps
:1
to90
encoding
:'JPEG'
(hardware accelerated),'GIF'
,'PNG'
,'PPM'
,'TGA'
,'BMP'
(see mmal_encodings.h for others)quality
: 1 - 100 (JPEG encoding quality)
Pause Capture
raspberryPiCamera.pause(callback);
Resume Capture
raspberryPiCamera.resume(callback);
Stop Capture
raspberryPiCamera.stop(callback);