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

@nouvellecuisine/nccamera

v1.7.2

Published

Electron integration for node-gphoto2

Downloads

19

Readme

nccamera

Electron integration for node-gphoto2.

Usage

Initialization

const NCCamera = require('@nouvellecuisine/nccamera');

const nccamera = new NCCamera({
  autostart: true,
  callback: image => {
    // Do something with image
  },
});

The constructor takes a dictionary of options as parameter with the following keys:

  • autostart: Boolean. Live Preview will be started automatically as soon as the camera is ready.
  • callback: Function. Called for each frame of the Live Preview that should be displayed by the client.

Trigger Auto-Focus

nccamera.autofocus();

The camera will try to focus the current view.

autofocus takes no parameters. It returns a promise that resolves if the command was sent successfully. However, there is no way to know if the camera has finished focusing or has managed to do it.

Capture Image

nccamera.capture(autofocus).then(
  image => {
    // Do something with image
  },
  () => console.error('Capture failed')
);

The camera will take a picture.

capture takes one parameter:

  • autofocus: Boolean. Tells the camera to trigger auto-focus before taking the picture. If true, the operation will be retried until focus is obtained or up to 5 times.

This returns a promise which resolves with the image data. It fails if no focus could be obtained.

Capture Video

nccamera.startVideo();

nccamera.stopVideo('/tmp/foo.mov').then(() => {
  // Process video file
});

The camera will take a video. path is the path on the host where video file will be written.

Please note the following limitations:

  • The video will not fit in the camera's RAM so a memory card should be inserted in the camera.
  • The provided path should not exist, otherwise it will not be overwritten.
  • A temporary file will be created in the same directory as the given path.

Example of using image data

Writing to a PixiJS texture

// Create blob URL from data
const arraybuffer = Uint8Array.from(image).buffer;
const blob = new Blob([arraybuffer], { type: 'image/jpeg' });
const blobUrl = URL.createObjectURL(blob);

// Load it as an image, then draw as texture when the image is ready
const img = new Image();
img.addEventListener('load', () => {
  URL.revokeObjectURL(blobUrl);
  const texture = new PIXI.Texture(new PIXI.BaseTexture(img));
  const oldTexture = videoSprite.texture;
  videoSprite.texture = texture;
  oldTexture.destroy(true);
});
img.src = blobUrl;

Writing to an image

const encoded = Buffer.from(image).toString('base64');
document.getElementById('capture').src = 'data:image/jpeg;base64,' + encoded;

Debug tools

The module includes a GUI debug tool that allows changing some configuration settings on the camera. Press the c key on your keyboard to open it.