GithubHelp home page GithubHelp logo

node-gphoto2's Introduction

node-gphoto2

Build Status NPM version

Become a Patron

A Node.js wrapper for libgphoto2. Useful for remote controlling of DSLRs and other digital cameras supported by gphoto2.

The included test application currently allows you to

  • receive a live preview of your camera (if supported). Tested with an EOS 550D on a 2010 iMac at ~17 fps using Chrome (Safari doesn't work and FF is slow as hell).
  • query a list of available configuration options
  • query the values of specific configuration options

The test suite can be run using npm test. There's also a small test application (npx coffee examples/server.coffee) which runs on http://localhost:1337 and allows to change camera settings and to take pictures.

Prerequisites

  • Node.js: versions 10 (LTS), 12 (LTS), 13 (current)
  • libgphoto2: ~2.5.x - via brew install libgphoto2, apt-get install libgphoto2-dev or download and build from http://www.gphoto.org/proj/libgphoto2/
  • pkg-config | dpkg (used for dependency checking)
  • clang compiler

Test/dev prerequisites

  • async
  • coffee-script
  • mocha
  • pre-commit
  • should
  • sinon
  • superagent

Test-server prerequisites

  • express
  • jade
  • underscore

Installation

After installing the dependencies, just install using:

npm install gphoto2

If it fails, please thoroughly check the output - link errors usually indicate missing dependencies. Also, the script tries to detect wether libgphoto2 is correctly installed - if this check fails although you properly installed it, please report :)

Usage

This example only shows how to achieve certain tasks, it's not meant to be executed without any asynchronous control flow logic.

var fs = require('fs');
var gphoto2 = require('gphoto2');
var GPhoto = new gphoto2.GPhoto2();

// Negative value or undefined will disable logging, levels 0-4 enable it.
GPhoto.setLogLevel(1);
GPhoto.on('log', function (level, domain, message) {
  console.log(domain, message);
});

// List cameras / assign list item to variable to use below options
GPhoto.list(function (list) {
  if (list.length === 0) return;
  var camera = list[0];
  console.log('Found', camera.model);

  // get configuration tree
  camera.getConfig(function (er, settings) {
    console.log(settings);
  });

  // Set configuration values
  camera.setConfigValue('capturetarget', 1, function (er) {
    //...
  });

  // Take picture with camera object obtained from list()
  camera.takePicture({download: true}, function (er, data) {
    fs.writeFileSync(__dirname + '/picture.jpg', data);
  });

  // Take picture and keep image on camera
  camera.takePicture({
    download: true,
    keep: true
  }, function (er, data) {
    fs.writeFileSync(__dirname + '/picture.jpg', data);
  });

  // Take picture without downloading immediately
  camera.takePicture({download: false}, function (er, path) {
    console.log(path);
  });

  // Take picture and download it to filesystem
  camera.takePicture({
    targetPath: '/tmp/foo.XXXXXX'
  }, function (er, tmpname) {
    fs.renameSync(tmpname, __dirname + '/picture.jpg');
  });

  // Download a picture from camera
  camera.downloadPicture({
    cameraPath: '/store_00020001/DCIM/100CANON/IMG_1231.JPG',
    targetPath: '/tmp/foo.XXXXXX'
  }, function (er, tmpname) {
    fs.renameSync(tmpname, __dirname + '/picture.jpg');
  });

  // Get preview picture (from AF Sensor, fails silently if unsupported)
  camera.takePicture({
    preview: true,
    targetPath: '/tmp/foo.XXXXXX'
  }, function (er, tmpname) {
    fs.renameSync(tmpname, __dirname + '/picture.jpg');
  });
});

Versioning

This project uses Semantic versioning.

Contributors

node-gphoto2's People

Contributors

bitdeli-chef avatar bmcbarron avatar catesq avatar dependabot[bot] avatar jnordberg avatar lpinca avatar lwille avatar michaelkoetter avatar mscdex avatar paulrupek avatar philipptrenz avatar pxe-la avatar sija avatar wolfg1969 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-gphoto2's Issues

Trying to compile under linux/ubuntu

I added #include "stdio.h" to helper.cc -- but now I'm in trouble

[1/9] cxx: src/preview.cc -> build/Release/src/preview_1.o
[2/9] cxx: src/camera_helpers.cc -> build/Release/src/camera_helpers_2.o
../src/camera_helpers.cc:6:11: error: redefinition of 'cv' as different kind of symbol
namespace cv = cvv8;
          ^
In file included from ../src/camera_helpers.cc:1:
../src/camera.h:5:3: note: previous definition is here
  namespace cv = cvv8;
  ^
../src/camera_helpers.cc:253:15: error: no matching function for call to 'gp_file_get_data_and_size'
          retval = gp_file_get_data_and_size (file, &req->data, &req->length);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/camera_helpers.cc:1:
In file included from ../src/camera.h:3:
In file included from ../src/binding.h:5:
In file included from /usr/include/gphoto2/gphoto2-camera.h:54:
In file included from /usr/include/gphoto2/gphoto2-filesys.h:36:
/usr/include/gphoto2/gphoto2-file.h:151:5: note: candidate function not viable: no known conversion from
      'size_t *' to 'unsigned long *' for 3rd argument
int gp_file_get_data_and_size (CameraFile*, const char **data,
    ^
4 diagnostics generated.
Waf: Leaving directory `/home/sam/work/node-gphoto2/build'
Build failed:  -> task failed (err #1): 
    {task: cxx camera_helpers.cc -> camera_helpers_2.o}
make: *** [all] Error 1

Assertion failed (InternalFieldCount)

Hi!

Node dies on assertion if I run the following code:

new require('gphoto2').GPhoto2();

Node error:

Assertion failed: (handle->InternalFieldCount() > 0), function Wrap, file ../src/node_object_wrap.h, line 71.
Abort trap: 6

GPhoto2 object gets garbage collected

Despite of having a v8::Persistentreference in the GPCamera object, the GPhoto2 object gets garbage collected when the camera object is contained in a closure:

gphoto.list(function(cameras) {
  server = http.createServer(function(req, res){
    camera.getPreview(function(er, data){
      res.writeHead(200, {'Content-Type': 'image/jpeg', 'Content-Length':data.length});
      res.write(data);
    }})

npm install fails on MAC 10.9.3

npm install fails on MAC 10.9.3 see the log below, it says 'gphoto2/gphoto2-camera.h' not found while it is there in the right path.

Appreciate some help here.

[email protected] preinstall /Users/lakshman/node-gphoto2
((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild

/opt/local/bin/pkg-config
/usr/local/bin/brew
/usr/local/Cellar/libgphoto2/2.5.1/bin/gphoto2-port-config
/usr/local/Cellar/libgphoto2/2.5.1/bin/gphoto2-config
/usr/local/Cellar/libgphoto2/2.5.1/include/gphoto2/ (18 files)
/usr/local/Cellar/libgphoto2/2.5.1/lib/libgphoto2.6.dylib
/usr/local/Cellar/libgphoto2/2.5.1/lib/libgphoto2_port.10.dylib
/usr/local/Cellar/libgphoto2/2.5.1/lib/libgphoto2/ (65 files)
/usr/local/Cellar/libgphoto2/2.5.1/lib/libgphoto2_port/ (7 files)
/usr/local/Cellar/libgphoto2/2.5.1/lib/pkgconfig/ (2 files)
/usr/local/Cellar/libgphoto2/2.5.1/lib/udev/check-ptp-camera
/usr/local/Cellar/libgphoto2/2.5.1/lib/ (2 other files)
/usr/local/Cellar/libgphoto2/2.5.1/share/doc/ (54 files)
/usr/local/Cellar/libgphoto2/2.5.1/share/libgphoto2/ (6 files)
/usr/local/Cellar/libgphoto2/2.5.1/share/man/ (2 files)
CXX(target) Release/obj.target/gphoto2/src/autodetect.o
../src/autodetect.cc:3:10: fatal error: 'gphoto2/gphoto2-camera.h' file not
found

include <gphoto2/gphoto2-camera.h>

     ^

1 error generated.
make: *** [Release/obj.target/gphoto2/src/autodetect.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:215:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:674:10)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/lakshman/node-gphoto2
gyp ERR! node -v v0.8.5
gyp ERR! node-gyp -v v0.6.3
gyp ERR! not ok
npm ERR! [email protected] preinstall: ((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild
npm ERR! sh "-c" "((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild" failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls gphoto2
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/lakshman/node-gphoto2
npm ERR! node -v v0.8.5
npm ERR! npm -v 1.1.46
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/lakshman/node-gphoto2/npm-debug.log
npm ERR! not ok code 0

Live preview not working in Safari

When using Safari, only a single image is loaded. It seems to be a "feature" of Safari not to reload an image if the src attribute is changed. As creating new Image() is way to slow, you have to use Chrome.

Take a picture

Capture and download a picture from the camera.

The first implementation capture the picture to memory and pass the Buffer containing the picture to the callback function.

A more elaborate implementation would stream the picture from the camera, if the driver should support it, and emit the data chunk by chunk through an EventEmitter.

How to use live preview from example

Hi !

Very nice work.
I've been trying to run the examples, but I'm not able to see the live preview :
http://localhost:1337/preview returns nothing on Chrome and bad image on firefox (the image can not be displayed because it contains error)

What is the process to look at the liveview in the browser ?

Thanks

Read/Write camera configuration values

Camera object should provide getConfigValue and setConfigValue methods to asynchronously read/write configuration Values.

GetConfigValue should accept both a single String but also a String[] for key, and return an Object for the latter case.
SetConfigValue should accept key,value parameters but also an Object { key:value, key:value }.

Both methods take a Callback function as the last parameter.

Update npm with v0.1.2

v0.1.1 is listed as most recent in npm. I'm having some trouble with libgphoto2.4 and libgphoto2.5 both built on this system in /usr and /usr/local, I think I screwed up somewhere. I think starting fresh with v0.1.2 in npm would be helpful.

Test failures with RaspberryPi and Nikon D700

Hey,

I grabbed a fresh copy of whezzy and performed a test run with following errors:

gphoto2:

gphoto2         2.5.2          gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.2          all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking

nodejs:

v0.10.5

I pasted it at pastebin to be easier to read:
http://pastebin.mozilla.org/2507055

Installing gphoto2 on ubuntu 12.04

Hello,
I'm trying to install gphoto2 on my ubuntu 12.04 machine, with no luck.

I have node 0.10.3, npm 1.2.17, clang 3.0, and libgphoto2 2.4.13.

I tried to run a npm install gphoto2, tried with sudo, tried to install it globally sudo npm install gphoto2 -g and it always fails like this

npm WARN engine [email protected]: wanted: {"node":"0.8.x"} (current: {"node":"v0.10.3","npm":"1.2.17"})

> [email protected] install /usr/lib/node_modules/gphoto2
> node-gyp rebuild

make: entrant dans le répertoire « /usr/lib/node_modules/gphoto2/build »
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
  CXX(target) Release/obj.target/gphoto2/src/binding.o
  CXX(target) Release/obj.target/gphoto2/src/camera.o
../src/camera.cc: In static member function ‘static v8::Handle<v8::Value> GPCamera::TakePicture(const v8::Arguments&)’:
../src/camera.cc:83:3: erreur: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/bigx/.node-gyp/0.10.3/deps/uv/include/uv.h:1411:15: erreur:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/camera.cc: In static member function ‘static v8::Handle<v8::Value> GPCamera::DownloadPicture(const v8::Arguments&)’:
../src/camera.cc:165:3: erreur: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/bigx/.node-gyp/0.10.3/deps/uv/include/uv.h:1411:15: erreur:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/camera.cc: In static member function ‘static v8::Handle<v8::Value> GPCamera::GetConfig(const v8::Arguments&)’:
../src/camera.cc:193:3: erreur: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/bigx/.node-gyp/0.10.3/deps/uv/include/uv.h:1411:15: erreur:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
../src/camera.cc: In static member function ‘static v8::Handle<v8::Value> GPCamera::SetConfigValue(const v8::Arguments&)’:
../src/camera.cc:302:3: erreur: invalid conversion from ‘void (*)(uv_work_t*) {aka void (*)(uv_work_s*)}’ to ‘uv_after_work_cb {aka void (*)(uv_work_s*, int)}’ [-fpermissive]
/home/bigx/.node-gyp/0.10.3/deps/uv/include/uv.h:1411:15: erreur:   initializing argument 4 of ‘int uv_queue_work(uv_loop_t*, uv_work_t*, uv_work_cb, uv_after_work_cb)’ [-fpermissive]
make: *** [Release/obj.target/gphoto2/src/camera.o] Erreur 1
make: quittant le répertoire « /usr/lib/node_modules/gphoto2/build »
gyp ERR! build error 

You say that the prerequisites are libgphoto2 2.5.0, is it the source of the problem I have? Or is is related to the version of node I use?

Any idea?

The aim is to run that stuff on a raspberry pi later on. To do some timelapsing.

Regards,

Xavier

Build Issue on OSX Lion

node-waf configure build
Checking for program g++ or c++          : clang 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
Checking for libgphoto2                  : yes 
Checking for libgphoto2_port             : yes 
'configure' finished successfully (0.070s)
Waf: Entering directory `/Users/schappetj/CameraControl/node-gphoto2/build'
[1/9] cxx: src/preview.cc -> build/Release/src/preview_1.o
[2/9] cxx: src/autodetect.cc -> build/Release/src/autodetect_2.o
[3/9] cxx: src/binding.cc -> build/Release/src/binding_2.o
[4/9] cxx: src/camera.cc -> build/Release/src/camera_2.o
../src/preview.cc:28:3: error: no matching function for call to 'gp_context_set_error_func'
  gp_context_set_error_func (context, error_func, NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/gphoto2/gphoto2/gphoto2-context.h:89:6: note: candidate function not viable: no known conversion from 'void
      (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextErrorFunc' (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument
void gp_context_set_error_func     (GPContext *context,
     ^
../src/preview.cc:29:2: error: no matching function for call to 'gp_context_set_status_func'
        gp_context_set_status_func (context, error_func, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/gphoto2/gphoto2/gphoto2-context.h:91:6: note: candidate function not viable: no known conversion from 'void
      (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextStatusFunc' (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument
void gp_context_set_status_func    (GPContext *context,
     ^
2 errors generated.
Waf: Leaving directory `/Users/schappetj/CameraControl/node-gphoto2/build'
Build failed:  -> task failed (err #1): 
        {task: cxx preview.cc -> preview_1.o}
make: *** [all] Error 1

takePicture a file descriptor opened causing "too many files opened" error

It seems like each time takePicture is called, a new file descriptor is created and never closed, bringing to an error in the long run when no more file descriptor can be created.

You can just loop a takePicture call and launch this shell command
lsof | grep node

to see how many opened files you have

Can you confirm it's a file descriptor leak?

Runtime error

Hey,

Though I was facing compilation issues while installing the module, I somehow managed to install the module. Now when I execute a test script it gives me an assertion failure:

node: /usr/local/include/node/node_object_wrap.h:62: void node::ObjectWrap::Wrap(v8::Handlev8::Object): Assertion `handle->InternalFieldCount() > 0' failed.
Aborted

Can you help me solve this?

node -v 0.6.11
npm -v 1.1.1
os: linux mint 12

Can't take more than one picture

Hey,

I figured out that you have to reset the usb port before you can take a second picture. Am I the only one having this issue?

error: invalid conversion from ‘void (*)(GPContext*, ....

I discovered your great module, but unfortunately I do not even install it with npm ... I get this error: (I try with different version of node.. but always same issue) And ma version of gphoto2 and libgphoto2 it's 2.4.14

make: Entering directory `/home/chesnel/src/take_picture/node_modules/gphoto2/build'
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
  CXX(target) Release/obj.target/gphoto2/src/binding.o
  CXX(target) Release/obj.target/gphoto2/src/camera.o
  CXX(target) Release/obj.target/gphoto2/src/camera_helpers.o
  CXX(target) Release/obj.target/gphoto2/src/gphoto.o
../src/gphoto.cc: In constructor ‘GPhoto2::GPhoto2()’:
../src/gphoto.cc:17:59: error: invalid conversion from ‘void (*)(GPContext*, const char*, void*) {aka void (*)(_GPContext*, const char*, void*)}’ to ‘GPContextErrorFunc {aka void (*)(_GPContext*, const char*, __va_list_tag*, void*)}’ [-fpermissive]
In file included from /usr/local/include/gphoto2/gphoto2-abilities-list.h:28:0,
                 from /usr/local/include/gphoto2/gphoto2-camera.h:50,
                 from ../src/binding.h:6,
                 from ../src/gphoto.h:3,
                 from ../src/gphoto.cc:1:
/usr/local/include/gphoto2/gphoto2-context.h:113:6: error:   initializing argument 2 of ‘void gp_context_set_error_func(GPContext*, GPContextErrorFunc, void*)’ [-fpermissive]
../src/gphoto.cc:18:61: error: invalid conversion from ‘void (*)(GPContext*, const char*, void*) {aka void (*)(_GPContext*, const char*, void*)}’ to ‘GPContextStatusFunc {aka void (*)(_GPContext*, const char*, __va_list_tag*, void*)}’ [-fpermissive]
In file included from /usr/local/include/gphoto2/gphoto2-abilities-list.h:28:0,
                 from /usr/local/include/gphoto2/gphoto2-camera.h:50,
                 from ../src/binding.h:6,
                 from ../src/gphoto.h:3,
                 from ../src/gphoto.cc:1:
/usr/local/include/gphoto2/gphoto2-context.h:115:6: error:   initializing argument 2 of ‘void gp_context_set_status_func(GPContext*, GPContextStatusFunc, void*)’ [-fpermissive]
make: *** [Release/obj.target/gphoto2/src/gphoto.o] Error 1
make: Leaving directory `/home/chesnel/src/take_picture/node_modules/gphoto2/build'

I really hope you can help me... I can't wait to play with ! Thanks...

Can't install via npm - Output included. I tried using both node 6.14 and 6.18

Any ideas?

Just doing a npm install gphoto2

I believe I have all of the deps.

npm http GET https://registry.npmjs.org/gphoto2
npm http 304 https://registry.npmjs.org/gphoto2

[email protected] preinstall /Users/cfletcher/node_modules/gphoto2
make

node-waf configure build
Checking for program g++ or c++          : clang 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /Users/cfletcher/.nvm/v0.6.18 
Checking for libgphoto2                  : yes 
Checking for libgphoto2_port             : yes 
'configure' finished successfully (0.053s)
Waf: Entering directory `/Users/cfletcher/node_modules/gphoto2/build'
[1/9] cxx: src/preview.cc -> build/Release/src/preview_1.o
[2/9] cxx: src/autodetect.cc -> build/Release/src/autodetect_2.o
[3/9] cxx: src/binding.cc -> build/Release/src/binding_2.o
[4/9] cxx: src/camera.cc -> build/Release/src/camera_2.o
[5/9] cxx: src/camera_helpers.cc -> build/Release/src/camera_helpers_2.o
[6/9] cxx: src/gphoto.cc -> build/Release/src/gphoto_2.o
[7/9] cxx: src/preview.cc -> build/Release/src/preview_2.o
../src/preview.cc:28:3: error: no matching function for call to 'gp_context_set_error_func'
  gp_context_set_error_func (context, error_func, NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:89:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextErrorFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_error_func     (GPContext *context,
     ^
../src/preview.cc:29:2: error: no matching function for call to 'gp_context_set_status_func'
        gp_context_set_status_func (context, error_func, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:91:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextStatusFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_status_func    (GPContext *context,
     ^
2 errors generated.
../src/preview.cc:28:3: error: no matching function for call to 'gp_context_set_error_func'
  gp_context_set_error_func (context, error_func, NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:89:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextErrorFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_error_func     (GPContext *context,
     ^
../src/preview.cc:29:2: error: no matching function for call to 'gp_context_set_status_func'
        gp_context_set_status_func (context, error_func, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:91:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextStatusFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_status_func    (GPContext *context,
     ^
2 errors generated.
../src/camera_helpers.cc:306:6: error: use of undeclared identifier 'gp_file_get_type'
  if(gp_file_get_type(file, &type) == GP_OK && type == GP_FILE_ACCESSTYPE_FD){
     ^
../src/camera_helpers.cc:324:25: error: use of undeclared identifier 'gp_file_get_type'
  if(retval == GP_OK && gp_file_get_type(file, &type) == GP_OK && type == GP_FILE_ACCESSTYPE_FD){
                        ^
2 errors generated.
../src/gphoto.cc:9:3: error: no matching function for call to 'gp_context_set_error_func'
  gp_context_set_error_func (this->context_, onError, NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:89:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextErrorFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_error_func     (GPContext *context,
     ^
../src/gphoto.cc:10:3: error: no matching function for call to 'gp_context_set_status_func'
  gp_context_set_status_func (this->context_, onStatus, NULL);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/libgphoto2/2.5.0/include/gphoto2/gphoto2/gphoto2-context.h:91:6: note: candidate function not viable: no known conversion from 'void (GPContext *, const char *, __va_list_tag *, void *)' to 'GPContextStatusFunc'
      (aka 'void (*)(GPContext *, const char *, void *)') for 2nd argument;
void gp_context_set_status_func    (GPContext *context,
     ^
2 errors generated.
Waf: Leaving directory `/Users/cfletcher/node_modules/gphoto2/build'
Build failed:
 -> task failed (err #1): 
    {task: cxx preview.cc -> preview_1.o}
 -> task failed (err #1): 
    {task: cxx preview.cc -> preview_2.o}
 -> task failed (err #1): 
    {task: cxx camera_helpers.cc -> camera_helpers_2.o}
 -> task failed (err #1): 
    {task: cxx gphoto.cc -> gphoto_2.o}
make: *** [all] Error 1
npm ERR! [email protected] preinstall: `make`
npm ERR! `sh "-c" "make"` failed with 2
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make
npm ERR! You can get their info via:
npm ERR!     npm owner ls gphoto2
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 12.2.1
npm ERR! command "node" "/Users/cfletcher/.nvm/v0.6.18/bin/npm" "install" "gphoto2"
npm ERR! cwd /Users/cfletcher/.nvm/bin
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.21
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: `make`
npm ERR! message `sh "-c" "make"` failed with 2
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/cfletcher/.nvm/bin/npm-debug.log
npm not ok

'make' failed with exit code 2

Hi,

I'm trying to get node-gphoto2 running again on my raspberry pi, so I got a fresh copy of raspbian and used node 0.10.22 but I'm getting following error message:

npm install gphoto2
npm http GET https://registry.npmjs.org/gphoto2
npm http 304 https://registry.npmjs.org/gphoto2

> [email protected] preinstall /home/pi/raw/node_modules/gphoto2
> ((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild

/usr/bin/pkg-config
make: Entering directory `/home/pi/raw/node_modules/gphoto2/build'
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
  CXX(target) Release/obj.target/gphoto2/src/binding.o
  CXX(target) Release/obj.target/gphoto2/src/camera.o
  CXX(target) Release/obj.target/gphoto2/src/camera_helpers.o
  CXX(target) Release/obj.target/gphoto2/src/gphoto.o
../src/gphoto.cc: In constructor ‘GPhoto2::GPhoto2()’:
../src/gphoto.cc:17:59: error: invalid conversion from ‘void (*)(GPContext*, const char*, void*) {aka void (*)(_GPContext*, const char*, void*)}’ to ‘GPContextErrorFunc {aka void (*)(_GPContext*, const char*, __va_list, void*)}’ [-fpermissive]
/usr/include/gphoto2/gphoto2-context.h:113:6: error:   initializing argument 2 of ‘void gp_context_set_error_func(GPContext*, GPContextErrorFunc, void*)’ [-fpermissive]
../src/gphoto.cc:18:61: error: invalid conversion from ‘void (*)(GPContext*, const char*, void*) {aka void (*)(_GPContext*, const char*, void*)}’ to ‘GPContextStatusFunc {aka void (*)(_GPContext*, const char*, __va_list, void*)}’ [-fpermissive]
/usr/include/gphoto2/gphoto2-context.h:115:6: error:   initializing argument 2 of ‘void gp_context_set_status_func(GPContext*, GPContextStatusFunc, void*)’ [-fpermissive]
make: *** [Release/obj.target/gphoto2/src/gphoto.o] Error 1
make: Leaving directory `/home/pi/raw/node_modules/gphoto2/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/node/node-v0.10.22-linux-arm-pi/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.10.24+
gyp ERR! command "node" "/opt/node/node-v0.10.22-linux-arm-pi/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/raw/node_modules/gphoto2
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.11.0
gyp ERR! not ok 
npm ERR! [email protected] preinstall: `((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls gphoto2
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.10.24+
npm ERR! command "/opt/node/node-v0.10.22-linux-arm-pi/bin/node" "/opt/node/node-v0.10.22-linux-arm-pi/bin/npm" "install" "gphoto2"
npm ERR! cwd /home/pi/raw
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/raw/npm-debug.log
npm ERR! not ok code 0

node: symbol lookup error: _ZNK4cvv810NativeToJSIfEclIfEEN2v86HandleINS3_5ValueEEERKT_

Hi,

I'm running into following error trying to access the config.

The camera is detected and can be triggered to take Pictures, however trying to get the list of configurations like

camera.getConfig(function(err, settings){
  if(err){
    console.log("error: " + err);
  }
  console.log(settings);
});

I get following message:

node: symbol lookup error: ../node_modules/node-gphoto2/build/Release/gphoto2.node: undefined symbol: _ZNK4cvv810NativeToJSIfEclIfEEN2v86HandleINS3_5ValueEEERKT_

I tried it witha a Nikon D700 on a raspberry pi with

nodejs 0.10.3

and libgphoto 2.5.0

gphoto2         2.5.0          gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.0          all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking

and on ubuntu 12.10 x64, same versions, same error message

In addition, trying to set a value such as the f-number, I end up with error -2

camera.setConfigValue('/main/capturesettings/f-number', 8, function(er){
  console.log("error: " + er);
});

takePicture preview with Nikon D7000

takePicture with parameter preview:true fails silently with Nikon D7000.
takePicture with parameter downloading true is working fine.

Any known issues with Nikon?

Porting to NAN

The module needs porting to NAN in order to assure compability with previous and future versions of Node and V8.

Development is done in feature/nan.

related issues: #65

Tasks so far:

  • Replace bindings with NAN macros
  • Reimplement camera settings (were removed through removal of cvv8)
  • Refactor async functions to use NanAsyncWorker
  • Use injected (bunyan?) logger instead of logCallback

Taking pictures uses up memory

Hi,
I discovered that each time a picture is taken, memory about the size of an image is taken up and not freed at all, which ultimately results in a
child_process.js:24404: Uncaught Error: spawn ENOMEM

I'm using following code-snippet to take a picture:

camera.takePicture({
            download: false
        }, function(err, data) {
            if (err !== undefined) {
                log.error('Error taking picture: ' + err);
                return callback('Error taking picture: ' + err, undefined);
            }
            log.info('Picture taken [ ' + iso + ' | ' + aperture + ' | ' + shutterspeed + ' ]');

            bus = list[0].port.substring(4, 7);
            port = list[0].port.substring(8, 11);

            log.info('bus: ' + bus + ' port: ' + port);

            resetUSB(bus, port, function(err, success) {
                return callback(err, success);
            });

        });

The function resetUSB(...) is reseting the usb port as a workaround to issue #43

I'm using a raspberry pi running
node v0.10.21 and
gphoto2 2.5.2 gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2 2.5.2 all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0 gcc, ltdl, USB, serial without locking

thanks for your help

npm install build failure on ubuntu 12.04

Hello lwille,

I am receiving the following errors when trying to sudo npm install gphoto2:

../src/preview.cc:11:13: error: use of undeclared identifier 'stdout'
fprintf (stdout, "\n");

Build failed:
-> task failed (err #1):
{task: cxx preview.cc -> preview_1.o}
-> task failed (err #1):
{task: cxx camera_helpers.cc -> camera_helpers_2.o}

make: *** [all] Error 1
npm ERR! [email protected] preinstall: make
npm ERR! sh "-c" "make" failed with 2

Would this be because stdio.h is not included in preview.cc nor in camera.h ?

My prerequisites are:

node -v v0.8.3
npm -v 1.1.44
ubuntu installed clang

Thank you for your time.

bphoto

Build Question.

@lwille this project looks awesome and will definitely be a life saver!!! Thank you!!

I have run into this problem when trying to build or install this node package.

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
../src/autodetect.cc:3:10: fatal error: 'gphoto2/gphoto2-camera.h' file not found
#include <gphoto2/gphoto2-camera.h>

I am learning about node-gyp and have found a simple solution(hack) to get this project to build by replacing:

'link_settings': {
        'libraries': [
          '-lgphoto2',
          '-lgphoto2_port'
        ]
      },

with:

'include_dirs': [
          '/usr/local/Cellar/libgphoto2/2.5.5/include/gphoto2/',
          '/usr/local/Cellar/libgphoto2/2.5.5/lib',
        ],
     'libraries': [
        '<!@(pkg-config libgphoto2 --libs)',
        '<!@(pkg-config libgphoto2_port --libs)',
      ],

So I am wondering what can I do to improve this project and get the build to work without my hack?

Here is the output of brew list libgphoto2:

$ brew list libgphoto2                                                                                                       
/usr/local/Cellar/libgphoto2/2.5.5/bin/gphoto2-config
/usr/local/Cellar/libgphoto2/2.5.5/bin/gphoto2-port-config
/usr/local/Cellar/libgphoto2/2.5.5/include/gphoto2/ (18 files)
/usr/local/Cellar/libgphoto2/2.5.5/lib/libgphoto2.6.dylib
/usr/local/Cellar/libgphoto2/2.5.5/lib/libgphoto2_port.10.dylib
/usr/local/Cellar/libgphoto2/2.5.5/lib/libgphoto2/ (65 files)
/usr/local/Cellar/libgphoto2/2.5.5/lib/libgphoto2_port/ (7 files)
/usr/local/Cellar/libgphoto2/2.5.5/lib/pkgconfig/ (2 files)
/usr/local/Cellar/libgphoto2/2.5.5/lib/udev/check-ptp-camera
/usr/local/Cellar/libgphoto2/2.5.5/lib/ (2 other files)
/usr/local/Cellar/libgphoto2/2.5.5/share/doc/ (54 files)
/usr/local/Cellar/libgphoto2/2.5.5/share/libgphoto2/ (6 files)
/usr/local/Cellar/libgphoto2/2.5.5/share/man/ (2 files)

Thanks for your help! :-)

Test failures on Ubuntu 13.04 x64 / D700

Same versions of node.js and GPhoto as in #35, but running on Ubuntu 13.04 x64.
At least it doesn't segfault ;)

> [email protected] test /home/michael/node-gphoto2
> node_modules/mocha/bin/mocha

1..9
ok 1 node-gphoto2 should find attached cameras
ok 2 node-gphoto2 should provide a list of settings
not ok 3 node-gphoto2 should allow saving camera settings
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/michael/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
ok 4 node-gphoto2 should return a proper error code when something goes wrong
not ok 5 node-gphoto2 should be able to take a picture without downloading
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/michael/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
not ok 6 node-gphoto2 should be able to take a picture and download it to a buffer
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/michael/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
not ok 7 node-gphoto2 should be able to take a picture and download it to the file system
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/michael/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
ok 8 node-gphoto2 should be able to take a picture and download it later
not ok 9 node-gphoto2 should be able to take a preview picture and send it over a socket
  Error: timeout of 25000ms exceeded
      at null.<anonymous> (/home/michael/node-gphoto2/node_modules/mocha/lib/runnable.js:140:21)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
# tests 9
# pass 4
# fail 5
/home/michael/node-gphoto2/node_modules/should/lib/should.js:2561: Uncaught AssertionError: expected '0' to equal 'ffd8'
/home/michael/node-gphoto2/node_modules/should/lib/should.js:1199: Uncaught AssertionError: expected -1 to not exist

Error handling

Investigate: Preview stops "after a while" and libgphoto issues a -1 error.

Also implement #13 as default strategy if preview stops working.

gphoto2 --capture-tethered with node-gphoto2

I am trying to use the package node-gphoto2 for shooting with my camera in tethered mode. With gphoto2 i could just connect my camera and start gphoto like gphoto2 --capture-tethered. Which according to the gphoto docs does the following:

Lets gphoto2 wait for notifications from the camera that an object was added. This is useful for tethered capture, where pressing the shutter on the camera immediately transfer the image to the machine for processing.

I have searched the node-gphoto2 docs, but could not find how to accomplish this. Any help is welcome.

npm install fails on raspbian

On my RaspberryPi the install process crashes at the cpplint command.
The installation:

npm @1.4.9
node @v0.10.28

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.2          gcc, popt(m), exif, no cdk, no aa, jpeg, no readline
libgphoto2      2.5.2          all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking

The error:

pi@raspberrypi ~/photobox_node/node_modules/gphoto2 $ npm install

> [email protected] preinstall /home/pi/photobox_node/node_modules/gphoto2
> ((which pkg-config && pkg-config libgphoto2) || (which dpkg && dpkg -s libgphoto2-2-dev) || (which brew && brew list libgphoto2) || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild

/usr/bin/pkg-config
make: Entering directory `/home/pi/photobox_node/node_modules/gphoto2/build'
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
  CXX(target) Release/obj.target/gphoto2/src/binding.o
  CXX(target) Release/obj.target/gphoto2/src/camera.o
  CXX(target) Release/obj.target/gphoto2/src/camera_helpers.o
  CXX(target) Release/obj.target/gphoto2/src/gphoto.o
  SOLINK_MODULE(target) Release/obj.target/gphoto2.node
  SOLINK_MODULE(target) Release/obj.target/gphoto2.node: Finished
  COPY Release/gphoto2.node
make: Leaving directory `/home/pi/photobox_node/node_modules/gphoto2/build'

> [email protected] prepublish /home/pi/photobox_node/node_modules/gphoto2
> npm run cpplint


> [email protected] cpplint /home/pi/photobox_node/node_modules/gphoto2
> util/cpplint.sh

Error: Please follow Google's style guidelines
Done processing src/binding.cc
src/camera.h:3:  #ifndef header guard has wrong style, please use: NODE_MODULES_GPHOTO2_SRC_CAMERA_H_  [build/header_guard] [5]
src/camera.h:148:  #endif line should be "#endif  // NODE_MODULES_GPHOTO2_SRC_CAMERA_H_"  [build/header_guard] [5]
Done processing src/camera.h
src/binding.h:3:  #ifndef header guard has wrong style, please use: NODE_MODULES_GPHOTO2_SRC_BINDING_H_  [build/header_guard] [5]
src/binding.h:99:  #endif line should be "#endif  // NODE_MODULES_GPHOTO2_SRC_BINDING_H_"  [build/header_guard] [5]
Done processing src/binding.h
Done processing src/camera.cc
Done processing src/camera_helpers.cc
Done processing src/gphoto.cc
Done processing src/autodetect.cc
src/gphoto.h:3:  #ifndef header guard has wrong style, please use: NODE_MODULES_GPHOTO2_SRC_GPHOTO_H_  [build/header_guard] [5]
src/gphoto.h:72:  #endif line should be "#endif  // NODE_MODULES_GPHOTO2_SRC_GPHOTO_H_"  [build/header_guard] [5]
Done processing src/gphoto.h
Total errors found: 6

npm ERR! [email protected] cpplint: `util/cpplint.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] cpplint script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     util/cpplint.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls gphoto2
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.12.20+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cpplint"
npm ERR! cwd /home/pi/photobox_node/node_modules/gphoto2
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/photobox_node/node_modules/gphoto2/npm-debug.log
npm ERR! not ok code 0

npm ERR! [email protected] prepublish: `npm run cpplint`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepublish script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run cpplint
npm ERR! You can get their info via:
npm ERR!     npm owner ls gphoto2
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.12.20+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/pi/photobox_node/node_modules/gphoto2
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/photobox_node/node_modules/gphoto2/npm-debug.log
npm ERR! not ok code 0

I also have a question about running the tests: Why is the coffee file not compiled? The coffee-script package is installed globally and locally..
My output:

pi@raspberrypi ~/photobox_node/node_modules/gphoto2 $ npm test

> [email protected] test /home/pi/photobox_node/node_modules/gphoto2
> node_modules/mocha/bin/mocha


/home/pi/photobox_node/node_modules/gphoto2/test/camera.test.coffee:1
ion (exports, require, module, __filename, __dirname) { global[id] ?= require
                                                                    ^
SyntaxError: Unexpected token =
  at Module._compile (module.js:439:25)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at /home/pi/photobox_node/node_modules/gphoto2/node_modules/mocha/lib/mocha.js:172:27
  at Array.forEach (native)
  at Mocha.loadFiles (/home/pi/photobox_node/node_modules/gphoto2/node_modules/mocha/lib/mocha.js:169:14)
  at Mocha.run (/home/pi/photobox_node/node_modules/gphoto2/node_modules/mocha/lib/mocha.js:356:31)
  at Object.<anonymous> (/home/pi/photobox_node/node_modules/gphoto2/node_modules/mocha/bin/_mocha:366:16)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:906:3

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0

Thanks!

Segmentation fault on taking picture on Raspberry PI

I'm on a Raspeberry PI and try to connect to a Canon EOS 6D. I can get the list of connected camera but cannot take a picture or get the configuration of them.

I have a simple script :

var gphoto2 = require('gphoto2'),
    GPhoto = new gphoto2.GPhoto2();

GPhoto.list(function(list) {
    //I can get the list of cams
    console.log(list)
    if (list.length) {
        var cam = list[0];

        //From here the script simply leaves
        cam.getConfig(function(er, settings) {
            console.log(settings);
        });
    } else {
        console.log('No cam');
    }
});

When I launch as any other node script I get this (with a Segment fault) :

$ node test.js
[ { model: 'USB PTP Class Camera',
    port: 'usb:001,005',
    _gphoto2_ref_obj_: {} } ]
Segmentation fault

When I launched it with root privileges I get this (without Segment fault) :

$ sudo /home/pi/node-v0.10.22-linux-arm-pi/bin/node test.js
[ { model: 'USB PTP Class Camera',
    port: 'usb:001,005',
    _gphoto2_ref_obj_: {} } ]

Either way the config callback is never called.

Sidenote : Taking a picture and downloading it from gphoto2 command line works fine.

Some informations :

SYSTEM :

Linux raspberrypi 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6l GNU/Linux

$ cat /proc/cpuinfo
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000d

GPHOTO2 :

gphoto2         2.5.2          gcc, popt(m), exif, no cdk, no aa, jpeg, no readline
libgphoto2      2.5.2          all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking

Versions :

node : v0.10.22
npm : 1.3.14
python : 2.7.3

Any ideas ?

Command queue

To work around the "Camera Busy" error (-110), a command queue will be implemented.
When an API command is called, it is pushed to the queue. If the queue was empty before, the command is executed immediately.

The next command will be triggered by a "Camera Ready" event.

Pre install script doesn't seem to work on raspberry pi

Hello, i tried to install your package with no luck.
Here is the output:

Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the gphoto2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     (pkg-config libgphoto2 || dpkg -s libgphoto2-2-dev || (echo 'ERROR: libgphoto2 seems not to be installed.' 1>&2; exit 1)) && node-gyp rebuild

I defined the dependency like this (to get your latest commit):

"gphoto2": "git://github.com/lwille/node-gphoto2#cb93e97123cfdeca88001390efc6b4f0f903297d"

With node 0.10.2 on a raspbian and here is the output of dpkg -s libgphoto2-2-dev

Package: libgphoto2-2-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 6266
Maintainer: Debian PhotoTools Maintainers <[email protected]>
Architecture: armhf
Source: libgphoto2
Version: 2.4.14-2
Depends: libgphoto2-2 (= 2.4.14-2), libexif-dev, libusb-dev, libc-dev, pkg-config
Description: gphoto2 digital camera library (development files)
 The gphoto2 library can be used by applications to access various
 digital camera models, via standard protocols such as USB Mass Storage
 and PTP, or vendor-specific protocols.
 .
 This package contains the development files.
Homepage: http://www.gphoto.org/proj/libgphoto2/

I never succeeded to get your package working, either on ubuntu 12.04 or raspberry pi.

Any idea?

Regards,

Xavier

any chance building it on raspberry pi?

i have node 0.8.15 and node-gyp installed and I changed the target_arch to arm but still fails

ake: Entering directory `/home/pi/download/node_modules/gphoto2/build'
  CXX(target) Release/obj.target/gphoto2/src/autodetect.o
  CXX(target) Release/obj.target/gphoto2/src/binding.o
  CXX(target) Release/obj.target/gphoto2/src/camera.o
  CXX(target) Release/obj.target/gphoto2/src/camera_helpers.o
../src/camera_helpers.cc: In static member function âstatic void GPCamera::downloadPicture(GPCamera::take_picture_request*)â:
../src/camera_helpers.cc:302:70: error: invalid conversion from âsize_t* {aka unsigned int*}â to âlong unsigned int*â [-fpermissive]
/usr/include/gphoto2/gphoto2-file.h:153:5: error:   initializing argument 3 of âint gp_file_get_data_and_size(CameraFile*, const char**, long unsigned int*)â [-fpermissive]
make: *** [Release/obj.target/gphoto2/src/camera_helpers.o] Error 1
make: Leaving directory `/home/pi/download/node_modules/gphoto2/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:232:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Linux 3.2.27+
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/download/node_modules/gphoto2
gyp ERR! node -v v0.8.15
gyp ERR! node-gyp -v v0.8.1
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1

ubuntu 12.04 compile errors

Hello lwille,

i get this errors trying to compile on ubuntu 12.04

node-waf configure build
Checking for program g++ or c++          : clang
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for node path                   : not found
Checking for node prefix                 : ok /usr/local
Checking for libgphoto2                  : yes
Checking for libgphoto2_port             : yes
'configure' finished successfully (0.144s)
Waf: Entering directory `/var/www/lapseberry/node_modules/gphoto2/build'
[1/9] cxx: src/preview.cc -> build/Release/src/preview_1.o
[2/9] cxx: src/camera_helpers.cc -> build/Release/src/camera_helpers_2.o
../src/preview.cc:11:13: error: use of undeclared identifier 'stdout'
  fprintf  (stdout, "\n");
            ^
../src/preview.cc:12:13: error: use of undeclared identifier 'stdout'
  fprintf  (stdout, "*** Contexterror ***              \n");
            ^
../src/preview.cc:13:13: error: use of undeclared identifier 'stdout'
  vfprintf (stdout, format, args);
            ^
../src/preview.cc:14:13: error: use of undeclared identifier 'stdout'
  fprintf  (stdout, "data:%p\n", data);
            ^
../src/preview.cc:15:13: error: use of undeclared identifier 'stdout'
  fflush   (stdout);
            ^
../src/preview.cc:55:9: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
        printf("|");
        ^~~~~~
        wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:55:16: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [2]'
        printf("|");
               ^~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
../src/preview.cc:57:7: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
      printf("\n%.02f%%\n%d fps\033[2A\r",i/20000.0*100.0, cnt);
      ^~~~~~
      wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:57:14: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [21]'
      printf("\n%.02f%%\n%d fps\033[2A\r",i/20000.0*100.0, cnt);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
../src/preview.cc:58:14: error: use of undeclared identifier 'stdout'
      fflush(stdout);
             ^
../src/preview.cc:64:5: error: use of undeclared identifier 'sprintf'
    sprintf(filename, "./frames/frame%.05d.jpg", i);
    ^
../src/preview.cc:68:21: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
    if(ret< GP_OK){ printf("gp_file_new returned %d\n", ret); break;}
                    ^~~~~~
                    wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:68:28: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [25]'
    if(ret< GP_OK){ printf("gp_file_new returned %d\n", ret); break;}
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
../src/preview.cc:70:21: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
    if(ret< GP_OK){ printf("gp_camera_capture_preview returned %d\n", ret); break;}
                    ^~~~~~
                    wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:70:28: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [39]'
    if(ret< GP_OK){ printf("gp_camera_capture_preview returned %d\n", ret); break;}
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
../src/preview.cc:72:21: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
    if(ret< GP_OK){ printf("gp_file_get_data_and_size returned %d\n", ret); break;}
                    ^~~~~~
                    wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:72:28: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [39]'
    if(ret< GP_OK){ printf("gp_file_get_data_and_size returned %d\n", ret); break;}
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
../src/preview.cc:80:3: error: use of undeclared identifier 'printf'; did you mean 'wprintf'?
  printf("\n\n\n");
  ^~~~~~
  wprintf
/usr/include/wchar.h:598:12: note: 'wprintf' declared here
extern int wprintf (__const wchar_t *__restrict __format, ...)
           ^
../src/preview.cc:80:10: error: cannot initialize a parameter of type 'const wchar_t *' with an lvalue of type 'const char [4]'
  printf("\n\n\n");
         ^~~~~~~~
/usr/include/wchar.h:598:49: note: passing argument to parameter '__format' here
extern int wprintf (__const wchar_t *__restrict __format, ...)
                                                ^
19 errors generated.
Waf: Leaving directory `/var/www/lapseberry/node_modules/gphoto2/build'
Build failed:  -> task failed (err #1):
        {task: cxx preview.cc -> preview_1.o}

Can you help me?

Live Preview

I'm having trouble getting a live preview from a connected camera.

var camera = cameras [0];
camera.takePicture ({ preview: true }, function (error, data) {
});

I'm not getting an error so that's a good sign. The camera object is valid, I can take pictures and get configs.

Not sure how to check if my camera (Canon Rebel T3i) has support for live preview, I'm pretty sure that it does.

foo


wrong repo.

Corrupted image file

Hello, I installed this lib on my raspberry pi with :

  • node : 0.8.22
  • libgphoto2-2 and libgphoto2-2-dev : 2.4.14

And tried to take a shot with my eos 550d as presented in the exemple.

camera.takePicture({download: true}, function(er, data) {
    fs.writeFile("picture.jpg", data, function(err) {
        if (err) {
            console.log(err);
        } else {
            console.log("The file was saved!");
        }
    });
});

But the picture.jpg is always corrupted when I try to open it. With the following error: Not a JPEG file: starts with 0x00 0x00

Any idea?

Regards,

Xavier

Test failures on Raspberry Pi / D700

The Pi is running current Raspbian, node.js 0.10.5 and libgphoto 2.5.1.1:

gphoto2         2.5.1          gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.1.1        all camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.10.0         gcc, ltdl, USB, serial without locking

The camera is a Nikon D700.

Here's the mocha test log:

> [email protected] test /home/pi/node-gphoto2
> node_modules/mocha/bin/mocha

1..9
ok 1 node-gphoto2 should find attached cameras
ok 2 node-gphoto2 should provide a list of settings
not ok 3 node-gphoto2 should allow saving camera settings
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/pi/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
ok 4 node-gphoto2 should return a proper error code when something goes wrong
not ok 5 node-gphoto2 should be able to take a picture without downloading
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/pi/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
not ok 6 node-gphoto2 should be able to take a picture and download it to a buffer
  Error: timeout of 2000ms exceeded
      at null.<anonymous> (/home/pi/node-gphoto2/node_modules/mocha/lib/runnable.js:167:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

It only reports up to test case 6 of 9, after that it terminates with a segfault:

Program terminated with signal 11, Segmentation fault.
#0  0xb6cb3ebc in kill () from /lib/arm-linux-gnueabihf/libc.so.6
(gdb) bt
#0  0xb6cb3ebc in kill () from /lib/arm-linux-gnueabihf/libc.so.6
#1  0x0028f958 in ?? ()
#2  0x0028f958 in ?? ()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.