EDSDK (Canon camera) wrapper module for Node.js
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.
- List Cameras
- Camera Events
- Read Camera Properties
- Text
- Integer
- Flags (true/false)
- Options (named list values)
- Aperture
- Shutter Speed
- Exposure Compensation
- Integer Array
- Time
- Write Camera Properties
- Text Properties
- Integer
- Integer Array
- Time
- Take Picture
- Download To Directory
- Download To File
- Download To String (Base64)
- Live View
- Storage
- List Volumes
- List Directories and Files
- Download Thumbnail
- Download Files
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();
The package does not include the Canon EDSDK files. To install the package you will have to build a TGZ.
- Unpack the Canon EDSDK into
third_party
. Keep the package name as subdirectory.EDSDKv131520W.zip
→third_party/EDSDKv131520W
- Make sure the variable
edsdk_version
inbinding.gyp
matches the EDSDK version. (The numeric part of the package name) - Run
npm run package
- Look for
../node_packages/@dimensional/napi-canon-cameras.tgz
cd ../YourProject
(Switch tp your project directory)npm i ../node_packages/@dimensional/napi-canon-cameras.tgz
The current EDSDK versions have a bug in EDSDKTypes.h
. The keys are missing
their prefixes. This will result in a conflict at compile time.
You will need to fix the EdsObjectFormat
enum.
/*-----------------------------------------------------------------------------
ObjectFormat Code
-----------------------------------------------------------------------------*/
typedef enum
{
kEdsObjectFormat_Unknown = 0x00000000,
kEdsObjectFormat_Jpeg = 0x3801,
kEdsObjectFormat_CR2 = 0xB103,
kEdsObjectFormat_MP4 = 0xB982,
kEdsObjectFormat_CR3 = 0xB108,
kEdsObjectFormat_HEIF_CODE = 0xB10B,
} EdsObjectFormat;
package
- Create TGZ package for AddOnprebuild
- Build for 32 and 64bit Node.jsprebuild:x64
- Build for 64bit Node.jsprebuild:ia32
- Build for 32bit Node.jsbuild:docs
- Update API documentation in README.mdbuild:stubs
- Update and build stubs (needs prebuild AddOn)clean
- Remove build artifacts
Yes.