|
@@ -6,7 +6,7 @@ var express = require('express'),
|
|
|
path = require('path'),
|
|
path = require('path'),
|
|
|
fs = require('fs'),
|
|
fs = require('fs'),
|
|
|
cors = require('cors'),
|
|
cors = require('cors'),
|
|
|
- execSync = require('child_process').execSync;
|
|
|
|
|
|
|
+ exec = require('child_process').exec;
|
|
|
|
|
|
|
|
const app = express();
|
|
const app = express();
|
|
|
const port = process.env.PORT || 3000;
|
|
const port = process.env.PORT || 3000;
|
|
@@ -34,11 +34,18 @@ function capture() {
|
|
|
var filePath = path.join(picturePath, Date.now().toString());
|
|
var filePath = path.join(picturePath, Date.now().toString());
|
|
|
console.log('Taking picture', filePath);
|
|
console.log('Taking picture', filePath);
|
|
|
|
|
|
|
|
- execSync(`fswebcam --jpeg 95 --save ${filePath}.jpeg --resolution 800x600 --frames 10`);
|
|
|
|
|
|
|
+ exec(`fswebcam --jpeg 95 --no-banner --resolution 800x600 --frames 1 --skip 20 -D 1 --save ${filePath}.jpeg`, function (error, stdout, stderr) {
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ console.error(`exec error: ${error}`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(`stdout: ${stdout}`);
|
|
|
|
|
+ console.error(`stderr: ${stderr}`);
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
app.listen(port, function () {
|
|
app.listen(port, function () {
|
|
|
console.log(`Growcam listening on port ${port}`);
|
|
console.log(`Growcam listening on port ${port}`);
|
|
|
|
|
|
|
|
- setInterval(capture, 5 * 1000);
|
|
|
|
|
|
|
+ setInterval(capture, 30 * 1000);
|
|
|
});
|
|
});
|