npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pi-camera

v1.7.0

Published

A very lightweight promise based Node.js wrapper for the native Raspberry Pi Camera CLI tools.

Downloads

176

Readme

Pi-Camera

A very lightweight promise based Node.js wrapper for the native Raspberry Pi Camera CLI tools.

Note: This was written with the intent of NOT being a hand holding library, but rather just give you access to execute commands on the camera in a flexible way.

Want to Contribute or Help Out?

Feel free to head over to the GitHub page for Pi-Camera and submit comments, issues, pulls, and whatever else you'd like. I plan on adding features as I need them for my own projects so if something isn't happening fast enough for you why not fix it? (:

Installation

// NPM 5
npm install pi-camera

// Older NPM versions
npm install pi-camera --save

Basic usage

Raspistill (Image Capture)

const PiCamera = require('pi-camera');
const myCamera = new PiCamera({
  mode: 'photo',
  output: `${ __dirname }/test.jpg`,
  width: 640,
  height: 480,
  nopreview: true,
});

myCamera.snap()
  .then((result) => {
    // Your picture was captured
  })
  .catch((error) => {
     // Handle your error
  });

You may use the snapDataUrl method for capturing a photo in Data-URL format (i.e. for embedding it in a website) without saving it to disk.

const PiCamera = require('pi-camera');
const myCamera = new PiCamera({
  mode: 'photo',
  width: 640,
  height: 480,
  nopreview: true,
});

myCamera.snapDataUrl()
  .then((result) => {
    // Your picture was captured
    console.log('<img src="${result}">');
  })
  .catch((error) => {
     // Handle your error
  });

Raspivid (Video Capture)

const PiCamera = require('pi-camera');
const myCamera = new PiCamera({
  mode: 'video',
  output: `${ __dirname }/video.h264`,
  width: 1920,
  height: 1080,
  timeout: 5000, // Record for 5 seconds
  nopreview: true,
});

myCamera.record()
  .then((result) => {
    // Your video was captured
  })
  .catch((error) => {
     // Handle your error
  });

Something worth considering is that the Camera module captures videos in a .h264 format, which is raw and uncompressed. Most players do not support this format so you might want to convert your files into something like .mp4. You can read more about it here.

Flags and Options

The Raspistill and Raspivid commands support a good number of parameters and options.

Currently they're all stored in the same files, so you'll need to do your do diligence and make sure you're using the correct options and flags for what you're trying to do. A good list of them can be found here

What's the difference between Flags and Options?

Good question!

Flags are portions of the Raspistill and Raspivid commands that are passed and require no additional input to fuction like so:

# NOTE: Not a working command
raspistill --nopreview --raw --hflip --vflip

Options are portions of the Raspistill and Raspivid commands that are passed and require additional input to fuction like so:

# NOTE: Not a working command
raspistill --output some/path/here --width 1080 --height 720

While the command line tools support many flags and options they're not all configured in this lib. If you discover one that you need but isn't supported, consider testing it, adding it and making a PR.