2014-12-25 29 views
1

製作完一張圖片後,我的相機卡住了。我只是試圖使用exec命令,因爲它似乎是最簡單的方法。我使用canon eos 400d,覆盆子pi模型B和node.js版本0.10.28。謝謝你的幫助!node.js exec在樹莓派上用gphoto2製作圖片

var Camera = function(){ 
} 

Camera.prototype = { 
    sys: require('sys'), 
    exec: require('child_process').exec 
} 

Camera.prototype.takePicture = function(imageCount, nextImagePosition, callback){ 
    this.exec("gphoto2 --capture-image-and-download --filename '%Y%m%d%H%M%S.jpg' ",  
    function(error, stdout, stderr){ 
    console.log('stdout: ' + stdout); 
    console.log('stderr: ' + stderr); 
    if (error !== null) { 
     console.log('exec error: ' + error); 
    } 
    }); 
}; 
+0

什麼是'this'?你能發佈整個代碼嗎? –

+0

我更新了代碼,但正如我之前所述,我可以拍攝一張照片。之後,我的相機卡住了,我無法拍攝更多照片。當我在命令行上運行命令時,沒有這樣的問題。 – user934801

回答