lwille/node-gphoto2

Re-check the camera connection?

Opened this issue · 4 comments

How do I re-check if camera is connected?
This doesn't work. Whenever I reconnect my camera, it always say 'No camera detected'

var camera = null;

function checkCam(){
    GPhoto.list(function (list) {
        if (list.length){
            camera = list[0];
            console.log('Found', camera.model);
        }
    });
}

checkCam();

function shoot(){
    if(camera){
        camera.takePicture({download: false}, function (er, path) {
            if(err}{
                camera = null;
            }
        });
    }else{
        console.log('No camera detected');
        checkCam();
    }
}

I repeat the question - Is it possible to re-check camera connection?

I've tried destroying and creating new gphoto2 object each time, but it causes "segmentation fault" error.

F.ex:

var gphoto2 = require('gphoto2');
var camera = null;
var GPhoto = null;

function checkCam(){
    GPhoto = new gphoto2.GPhoto2();
    GPhoto.list(function (list) {
        if (list.length){
            camera = list[0];
            console.log('Found', camera.model);
        }
    });
}

checkCam();

function shoot(){
    if(camera){
        camera.takePicture({download: false}, function (er, path) {
            if(err}{
                GPhoto = null;
                camera = null;
            }
        });
    }else{
        console.log('No camera detected');
        checkCam();
    }
}

I can't imagine that I have to restart the whole app when camera goes sleep :-)
I mean, don't get me wrong - I admire your work and your time spent on this project, but what I'm asking is just basic functionality...

kindly,
Artur.

I did some research on my own and I see that re-connection isn't implemented :-/
Thanks for support! :-)

Kindly,
Artur.

You should probably turn off the "autopoweroff" settings of you camera by settings it's value to "0".
That's what i've done :-)

Hope it'll help you !

I'm sorry this is something the gphoto APIs don't support (and even the cameras may not be able to do it); I remember asking the original author about it long time ago - as always, feel free to get involved there.

The quickest solution I came up with 8 years ago was a usb-controlled switch and power cycle the camera (see #13)

I investigated disabling and re-enabling the entire USB port, but this is quite low-level and platform specific and gave more troubles than it actually helped to solve.