dimensional-de / napi-canon-cameras

Node AddOn Api module for Canon cameras
GNU General Public License v3.0
51 stars 18 forks source link
camera canon eos library napi node nodejs powershot usb

@dimensional/napi-canon-cameras

EDSDK (Canon camera) wrapper module for Node.js

Features

The EDSDK provides a lot of features and not all of them are implemented in the module. Our use case was a photo booth application.

Usage

import {
    Camera, CameraProperty, FileChangeEvent, ImageQuality,
    Option,
    watchCameras
} from '../';

process.on('SIGINT', () => process.exit());

// catch download request events
cameraBrowser.setEventHandler(
    (eventName, event) => {
        if (eventName === CameraBrowser.Events.DownloadRequest) {
            const file = (event as DownloadRequestEvent).file;
            console.log(file);
            const localFile = file.downloadToPath(__dirname + '/images');
            console.log(`Downloaded ${file.name}.`);

            process.exit();
        }
    }
);

// get first camera
const camera = cameraBrowser.getCamera();
if (camera) {
    console.log(camera);
    camera.connect();
    // configure
    camera.setProperties(
        {
            [CameraProperty.ID.SaveTo]: Option.SaveTo.Host,
            [CameraProperty.ID.ImageQuality]: ImageQuality.ID.LargeJPEGFine,
            [CameraProperty.ID.WhiteBalance]: Option.WhiteBalance.Fluorescent
        }
    );
    // trigger picture
    camera.takePicture();
} else {
    console.log('No camera found.');
}

// watch for camera events
watchCameras();

Build Package

The package does not include the Canon EDSDK files. To install the package you will have to build a TGZ.

  1. Unpack the Canon EDSDK into third_party. Keep the package name as subdirectory.
    • EDSDKv131800W.zipthird_party/EDSDKv131800W
  2. Make sure the variable edsdk_version in binding.gyp matches the EDSDK version. (The numeric part of the package name)
  3. Run npm run package
  4. Look for ../node_packages/@dimensional/napi-canon-cameras.tgz
  5. cd ../YourProject (Switch to your project directory)
  6. npm i ../node_packages/@dimensional/napi-canon-cameras.tgz

NPM Tasks

FAQ

Does the module work in Electron Applications?

Yes.