|
@@ -6,24 +6,7 @@ var express = require('express'),
|
|
|
path = require('path'),
|
|
path = require('path'),
|
|
|
fs = require('fs'),
|
|
fs = require('fs'),
|
|
|
cors = require('cors'),
|
|
cors = require('cors'),
|
|
|
- NodeWebcam = require('node-webcam');
|
|
|
|
|
-
|
|
|
|
|
-var opts = {
|
|
|
|
|
- quality: 100,
|
|
|
|
|
- saveShots: false,
|
|
|
|
|
- output: 'jpeg',
|
|
|
|
|
- device: false,
|
|
|
|
|
- setValues: {
|
|
|
|
|
- '"White Balance Temperature, Auto"': true
|
|
|
|
|
- },
|
|
|
|
|
- // device: '/dev/video2',
|
|
|
|
|
- // [location, buffer, base64]
|
|
|
|
|
- callbackReturn: 'location',
|
|
|
|
|
- verbose: true
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-//Creates webcam instance
|
|
|
|
|
-var Webcam = NodeWebcam.create(opts);
|
|
|
|
|
|
|
+ execSync = require('child_process').execSync;
|
|
|
|
|
|
|
|
const app = express();
|
|
const app = express();
|
|
|
const port = process.env.PORT || 3000;
|
|
const port = process.env.PORT || 3000;
|
|
@@ -45,35 +28,17 @@ app.get('/pictures', function (req, res, next) {
|
|
|
res.status(200).send({ pictures: entries.sort() });
|
|
res.status(200).send({ pictures: entries.sort() });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-app.get('/picture', function (req, res, next) {
|
|
|
|
|
- var tmp = JSON.parse(JSON.stringify(opts));
|
|
|
|
|
- tmp.callbackReturn = 'buffer';
|
|
|
|
|
-
|
|
|
|
|
- console.log(req.query)
|
|
|
|
|
-
|
|
|
|
|
- NodeWebcam.capture('/tmp/test', tmp, function (error, data) {
|
|
|
|
|
- if (error) {
|
|
|
|
|
- console.error(error);
|
|
|
|
|
- return res.status(500).end();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- res.status(200).send(data);
|
|
|
|
|
- });
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
app.use(express.static('public'));
|
|
app.use(express.static('public'));
|
|
|
|
|
|
|
|
function capture() {
|
|
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);
|
|
|
|
|
|
|
|
- NodeWebcam.capture(filePath, opts, function (error, data) {
|
|
|
|
|
- if (error) console.error(error);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ execSync(`fswebcam --jpeg 95 --save ${filePath}.jpeg --resolution 800x600 --frames 10`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
app.listen(port, function () {
|
|
app.listen(port, function () {
|
|
|
console.log(`Growcam listening on port ${port}`);
|
|
console.log(`Growcam listening on port ${port}`);
|
|
|
|
|
|
|
|
- setInterval(capture, 30 * 1000);
|
|
|
|
|
|
|
+ setInterval(capture, 5 * 1000);
|
|
|
});
|
|
});
|