Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

var version = '1.28';
var version = '1.29';

var args = process.argv.slice(2);

Expand Down Expand Up @@ -88,6 +88,16 @@ socket.on('take-photo', function(data){
takeImage();
});

socket.on('take-photo-webcam', function(data){
console.log("Taking a photo - WebCam");

photoStartTime = Date.now();
lastReceiveTime = data.time
takeId = data.takeId;

takeImage_WebCam();
});

socket.on('update-software', function(data){
console.log("Updating software");

Expand Down Expand Up @@ -125,8 +135,8 @@ function heartbeat() {
socket.emit('camera-online', {name: cameraName, ipAddress: ipAddress, hostName: hostName, version: version, updateInProgress: updateInProgress});
}

function getAbsoluteImagePath() {
return path.join(__dirname, imagePath, imageName);
function getAbsoluteImagePath(prefix='') {
return path.join(__dirname, imagePath, prefix + imageName);
}

function lookupIp() {
Expand Down Expand Up @@ -206,7 +216,7 @@ function takeImage() {
//'-w', 2592, // width
//'-h', 1944, // height
//'-t', 100, // how long should taking the picture take?
'-q', 90, // quality
'-q', 95, // quality
'-awb', 'fluorescent',
'-o', getAbsoluteImagePath() // path + name
];
Expand All @@ -217,6 +227,23 @@ function takeImage() {
imageProcess.on('exit', sendImage);
}

function takeImage_WebCam() {
var args = [
//'-w', 2592, // width
//'-h', 1944, // height
//'-t', 100, // how long should taking the picture take?
'-r', '1920x1080', // quality
'--no-banner',
getAbsoluteImagePath() // path + name
];

var imageProcess = spawn('fswebcam', args);
// The image should take about 5 seconds, if its going after 10 kill it!
setTimeout(function(){ imageProcess.kill()}, 10000);

imageProcess.on('exit', sendImage);
}

// To update the software we run git pull and npm install and then forcibily kill this process
// Supervisor will then restart it
function updateSoftware() {
Expand Down