Commit d7f82802 authored by Kylian ou Nathan's avatar Kylian ou Nathan
Browse files

Up

parent 9fdbb475
node_modules/
capture/
yarn.lock
\ No newline at end of file
const express = require('express')
const app = express()
const fs = require("fs");
const http = require('http');
const FormData = require('form-data');
const axios = require('axios');
const readline = require('readline');
const raspivid = require('raspivid');
/**
* TODO : DEBUG a replacer par une interface gpio
*/
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var httpServer = http.createServer(app);
httpServer.listen(8080);
/**
* ? Méthode permettant de filmer pendant 1 minutes
*/
function record() {
console.log("DEBUT ENREGISTREMENT")
var file = fs.createWriteStream(`${__dirname}/capture/${new Date().getTime()}.h264`);
var video = raspivid({
width: 1280,
height: 720,
framerate: 30,
timeout: 5 * 1000,
'codec': 'MJPEG'
});
video.pipe(file);
video.on("end", r => {
console.log("FIN ENREGISTREMENT")
})
}
/**
* ? Méthode permettant d'avertir le serveur de l'intrusion
*/
function intrusion() {
var formData = new FormData()
formData.append("type", "intrusion")
axios.post("http://lockhome.nrocher.fr/api", formData).then(res => {
console.log(res.data)
}).catch(err => {
console.error(err)
})
}
/**
* TODO : DEBUG : Doit être réplacé par un évenement d'un port GPIO (module de détection de mouvement)
*/
rl.on("line", input => {
switch (input) {
case "intrusion":
record()
intrusion()
break;
}
});
\ No newline at end of file
{
"dependencies": {
"axios": "^0.19.0",
"express": "^4.17.1",
"form-data": "^3.0.0",
"pi-camera": "^1.3.0",
"raspberry-pi-camera-native": "^0.0.0",
"raspivid": "^1.0.0",
"split-frames": "^2.4.2"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment