BOBINOSCOPE 9 years ago
parent
commit
61ae8a986e
8 changed files with 167 additions and 49 deletions
  1. 2
      app.js
  2. BIN
      public/img/footer/m-clotilde60.jpg
  3. BIN
      public/img/footer/m-clotilde60.xcf
  4. 20
      routes/index.js
  5. 102
      tools/tools-gphoto2.js
  6. 4
      tools/tools-photobooth.js
  7. 62
      views/index.ejs
  8. 26
      views/view.ejs

2
app.js

@ -99,7 +99,7 @@ function BOB_initConfig() {
prebuilt : "", prebuilt : "",
original : "" original : ""
}, },
footer : BOB_mod_path.resolve(__dirname, './public/img/footer', 'm-cloclo.jpg')
footer : BOB_mod_path.resolve(__dirname, './public/img/footer', 'm-clotilde60.jpg')
}; };
// Init PATH // Init PATH
cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final'); cfgConfig.paths.final = BOB_mod_path.resolve(__dirname, './public/img/final');

BIN
public/img/footer/m-clotilde60.jpg

Before After
Width: 1600  |  Height: 280  |  Size: 303 KiB

BIN
public/img/footer/m-clotilde60.xcf

20
routes/index.js

@ -15,14 +15,24 @@ var BOB_var_boothInProgress = 0;
var BOB_var_gamepad = require("gamepad"); var BOB_var_gamepad = require("gamepad");
var BOB_var_ipAddress = '127.0.0.1'; var BOB_var_ipAddress = '127.0.0.1';
var BOB_var_path = "/home/troll/workspace/bobinoscope";
var BOB_var_path = "/home/cocoon/workspace/bobinoscope";
BOB_mod_mkdirp.sync("public/printer/todo");
BOB_mod_mkdirp.sync("public/printer/done");
var BOB_var_killZone = {
top : 2,
bottom : 2,
left : 25,
right : 25
}
BOB_mod_mkdirp.sync(BOB_var_path+"/public/printer/todo");
BOB_mod_mkdirp.sync(BOB_var_path+"/public/printer/done");
/* GET home page. */ /* GET home page. */
BOB_mod_router.get('/bobinoscope', function(req, res, next) { BOB_mod_router.get('/bobinoscope', function(req, res, next) {
res.render('index', {serverIpAddress: BOB_var_ipAddress});
res.render('index', {
serverIpAddress: BOB_var_ipAddress,
killZone : BOB_var_killZone
});
}); });
/* GET view page. */ /* GET view page. */
BOB_mod_router.get('/', function(req, res, next) { BOB_mod_router.get('/', function(req, res, next) {
@ -69,7 +79,7 @@ BOB_mod_router.get('/print/bobinogramme/:pictId', function(req, res, next) {
}); });
BOB_mod_router.get('/print/list/todo', function(req, res, next) { BOB_mod_router.get('/print/list/todo', function(req, res, next) {
var todoPath = BOB_mod_path.join(BOB_var_path, '/public/img/final/'+req.params.pictId);
var todoPath = BOB_mod_path.join(BOB_var_path, '/public/printer/todo');
BOB_mod_fs.readdir(todoPath, function(pErr, pList) { BOB_mod_fs.readdir(todoPath, function(pErr, pList) {
res.json({error: pErr, todos: pList}) res.json({error: pErr, todos: pList})
}) })

102
tools/tools-gphoto2.js

@ -1,10 +1,12 @@
var BOB_mod_gm = require('gm').subClass({ imageMagick: true }); var BOB_mod_gm = require('gm').subClass({ imageMagick: true });
var BOB_mod_gphoto2 = require('gphoto2');
var BOB_var_gphoto = new BOB_mod_gphoto2.GPhoto2();
// var BOB_mod_gphoto2 = require('gphoto2');
// var BOB_var_gphoto = new BOB_mod_gphoto2.GPhoto2();
var BOB_mod_fs = require('fs'); var BOB_mod_fs = require('fs');
var BOB_mod_path = require('path'); var BOB_mod_path = require('path');
var BOB_mod_mkdirp = require('mkdirp'); var BOB_mod_mkdirp = require('mkdirp');
var BOB_mod_exec = require('child_process').exec;
var BOB_cfg_config = null; var BOB_cfg_config = null;
var BOB_var_camera = null; var BOB_var_camera = null;
@ -13,22 +15,29 @@ var BOB_module = {};
BOB_upCameraReference(function() {}); BOB_upCameraReference(function() {});
function BOB_takePicture(pCallback) {
BOB_mod_exec("gphoto2 --capture-image-and-download --filename=/tmp/bobine.jpg --force-overwrite", function(pErr, pStdout, pStderr) {
console.log("takjePixuter", pErr || pStdout || pStderr)
return pCallback(pErr)
})
}
function BOB_upCameraReference(pCallback) { function BOB_upCameraReference(pCallback) {
// List cameras / assign list item to variable to use below options // List cameras / assign list item to variable to use below options
if( BOB_var_camera === null ) {
BOB_var_gphoto.list(function (list) {
if (list.length === 0) {
return pCallback();
} else {
console.log(list)
BOB_var_camera = list[0];
console.log(BOB_var_camera.model);
return pCallback();
}
})
} else {
//if( BOB_var_camera === null ) {
// BOB_var_gphoto.list(function (list) {
// if (list.length === 0) {
// return pCallback();
// } else {
// console.log(list)
// BOB_var_camera = list[0];
// console.log(BOB_var_camera.model);
// return pCallback();
// }
// })
//} else {
return pCallback(); return pCallback();
}
//}
} }
BOB_module.getConfig = function(pCallback) { BOB_module.getConfig = function(pCallback) {
@ -41,21 +50,82 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) {
var pictOrig = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); var pictOrig = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]);
var pictPblt = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]); var pictPblt = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]);
BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId));
console.log("new")
BOB_takePicture(function (pErr) {
// If error occurs
if( pErr ) {
return pCallback(pErr)
// Else write file on ddisk
} else {
BOB_mod_mkdirp(destPath, function() {
copyFile("/tmp/bobine.jpg", pictOrig, function(pErr) {
return pCallback(pErr, pictOrig)
});
})
}
});
}
function copyFile(source, target, cb) {
var cbCalled = false;
var rd = BOB_mod_fs.createReadStream(source);
rd.on("error", function(err) {
done(err);
});
var wr = BOB_mod_fs.createWriteStream(target);
wr.on("error", function(err) {
done(err);
});
wr.on("close", function(ex) {
done();
});
rd.pipe(wr);
function done(err) {
if (!cbCalled) {
cb(err);
cbCalled = true;
}
}
}
BOB_module.takePictureNpm = function(pBoothId, pPictId, pCallback) {
var destPath = BOB_mod_path.join(BOB_cfg_config.paths.original, pBoothId);
var pbltPath = BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId);
var pictOrig = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]);
var pictPblt = BOB_mod_path.join(destPath, BOB_cfg_config.pictNames[pPictId]);
console.log("1");
BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId)); BOB_mod_mkdirp.sync(BOB_mod_path.join(BOB_cfg_config.paths.prebuilt, pBoothId));
console.log("2");
BOB_upCameraReference(function() { BOB_upCameraReference(function() {
console.log("3");
if( BOB_var_camera === null ) { if( BOB_var_camera === null ) {
return pCallback("No camera found"); return pCallback("No camera found");
} else { } else {
console.log("4");
BOB_var_camera.takePicture({download: true}, function (pErr, pData) { BOB_var_camera.takePicture({download: true}, function (pErr, pData) {
// If error occurs // If error occurs
if( pErr ) { if( pErr ) {
return pCallback(pErr) return pCallback(pErr)
// Else write file on ddisk // Else write file on ddisk
} else { } else {
console.log("5");
BOB_mod_mkdirp(destPath, function() { BOB_mod_mkdirp(destPath, function() {
console.log("6");
BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) { BOB_mod_fs.writeFile(pictOrig, pData, function(pErr) {
console.log("7");
// BOB_mod_gm(pictOrig) // BOB_mod_gm(pictOrig)
// .autoOrient() // .autoOrient()
// .gravity('Center') // .gravity('Center')
@ -78,4 +148,4 @@ BOB_module.takePicture = function(pBoothId, pPictId, pCallback) {
module.exports = function(pConfig) { module.exports = function(pConfig) {
BOB_cfg_config = pConfig; BOB_cfg_config = pConfig;
return BOB_module; return BOB_module;
}
}

4
tools/tools-photobooth.js

@ -59,7 +59,7 @@ function BOB_generateBooth(pBoothId, pType, pCallback) {
outPict.fill(BOB_cfg_config.background); outPict.fill(BOB_cfg_config.background);
outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height); outPict.drawRectangle(0, 0, BOB_cfg_config.booths[pType].resolution.width, BOB_cfg_config.booths[pType].resolution.height);
// Draw footer // Draw footer
outPict.draw('image Over 0,2070 1600,280 \''+BOB_cfg_config.footer+'\'');
outPict.draw('image Over 0,2100 1600,250 \''+BOB_cfg_config.footer+'\'');
BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) { BOB_cfg_config.pictNames.forEach(function(pPictName, pIndex) {
var cmdDraw = 'image Over'; var cmdDraw = 'image Over';
@ -84,7 +84,7 @@ function BOB_generateBooth(pBoothId, pType, pCallback) {
pCallback(pErr); pCallback(pErr);
} else { } else {
BOB_mod_gm(finalPict) BOB_mod_gm(finalPict)
.resize(600, null)
.resize(400, null)
.write(finalLdPict, function(pErr) { .write(finalLdPict, function(pErr) {
pCallback(pErr); pCallback(pErr);
}) })

62
views/index.ejs

@ -19,16 +19,29 @@
<div style="padding-top:1em"> <div style="padding-top:1em">
<div id="idViewCountdown" style="font-size:20em; display:none"></div> <div id="idViewCountdown" style="font-size:20em; display:none"></div>
<div id="idViewTrigger" style="display:block"> <div id="idViewTrigger" style="display:block">
<h1 class="cover-heading">Prends ta face !</h1>
<h1 class="cover-heading">Prends ta bobine !</h1>
<br/><br/>
<div style="width:800px;height:600px;position:relative;display:none">
<video id="player" autoplay="true" style="height:100%;width:100%;position:absolute;left:0;top:0"></video>
<div style="position:absolute;background:#3C0000;top:0;left:0;width:<%= killZone.left%>%;height:100%;opacity:0.9"></div>
<div style="position:absolute;background:#3C0000;top:0;right:0;width:<%= killZone.right%>%;height:100%;opacity:0.9"></div>
<div style="position:absolute;background:#3C0000;top:0;left:<%= killZone.left%>%;right:<%= killZone.right%>%;height:<%= killZone.top%>%;opacity:0.9"></div>
<div style="position:absolute;background:#3C0000;bottom:0;left:<%= killZone.left%>%;right:<%= killZone.right%>%;height:<%= killZone.bottom%>%;opacity:0.9"></div>
</div>
</div> </div>
<div id="idViewGenerating" style="display:none"> <div id="idViewGenerating" style="display:none">
<h1 class="cover-heading">Bobinogramme <i>en cours de génération...</i></h1> <h1 class="cover-heading">Bobinogramme <i>en cours de génération...</i></h1>
<br/><br/> <br/><br/>
<h3>Merci de bien vouloir patienter<br/>une dizaine de secondes</h3>
<h3>Merci de bien vouloir patienter<br/>une quinzaine de secondes</h3>
<br/>
<br/>
<div style="position:relative;width:100%;height:2px;background:#444">
<div id="idProgressBar" style="background:#fff;height:2px; width:0%;transition: all 200ms ease"></div>
</div>
</div> </div>
<div id="idViewBobinogramme" style="display:none"> <div id="idViewBobinogramme" style="display:none">
<img src="/img/final_ld/1438098902994.jpg" height="600px"/> <img src="/img/final_ld/1438098902994.jpg" height="600px"/>
<h3 class="cover-heading">Retrouve ton <b>bobinogramme</b> sur <br/>http://192.168.1.2:3000</h3>
<h3 class="cover-heading">Retrouve ton <b>bobinogramme</b> sur <br/>http://192.168.1.2</h3>
</div> </div>
</div> </div>
<div id="idViewDoIt" style="font-size:8em; height:600px; display:none"> <div id="idViewDoIt" style="font-size:8em; height:600px; display:none">
@ -102,7 +115,7 @@ var BOB_var_themes = {
$(document).ready(function() { $(document).ready(function() {
$('#idBtnClick').click(function() { $('#idBtnClick').click(function() {
BOB_runBooth();
//BOB_runBooth();
}) })
}) })
@ -157,6 +170,19 @@ function BOB_displayPictPreview(pBoothId, pPictureId, pCallback) {
}) })
} }
var BOB_var_progressTimer = new Date();
function BOB_lauchFakeProgressBar() {
setTimeout(function() {
var progress = (new Date() - BOB_var_progressTimer) / 20000 * 100;
$('#idProgressBar').css('width', progress+'%');
if( progress < 100 ) {
BOB_lauchFakeProgressBar();
}
}, 500)
}
function BOB_takeThe1Pictures() { function BOB_takeThe1Pictures() {
$.get('/dslr/takepicture/'+BOB_var_context.boothId+'/'+BOB_var_context.pictureId, function(pResponse) { $.get('/dslr/takepicture/'+BOB_var_context.boothId+'/'+BOB_var_context.pictureId, function(pResponse) {
if( pResponse.error ) { if( pResponse.error ) {
@ -175,7 +201,10 @@ function BOB_takeThe1Pictures() {
BOB_countdown(); BOB_countdown();
} else { } else {
$('#idViewCountdown').fadeOut(500, function() { $('#idViewCountdown').fadeOut(500, function() {
$('#idViewGenerating').fadeIn()
BOB_var_progressTimer = new Date();
$('#idProgressBar').css('width', '0');
$('#idViewGenerating').fadeIn();
BOB_lauchFakeProgressBar()
}) })
$.get('/booth/build/'+BOB_var_context.boothId, function(pResponse) { $.get('/booth/build/'+BOB_var_context.boothId, function(pResponse) {
$('#idViewBobinogramme > img').attr('src', '/img/final_ld/'+pResponse.boothId+'.jpg'); $('#idViewBobinogramme > img').attr('src', '/img/final_ld/'+pResponse.boothId+'.jpg');
@ -194,5 +223,26 @@ function BOB_takeThe1Pictures() {
}) })
} }
/*
(function(){
var mediaOptions = { audio: false, video: true };
</script>
if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
}
if (!navigator.getUserMedia){
return alert('getUserMedia not supported in this browser.');
}
navigator.getUserMedia(mediaOptions, success, function(e) {
console.log(e);
});
function success(stream){
var video = document.querySelector("#player");
video.src = window.URL.createObjectURL(stream);
}
})();
*/
</script>

26
views/view.ejs

@ -48,6 +48,10 @@
font-size: 1.2em; font-size: 1.2em;
} }
.classBoothItem {
margin: 5px 0
}
#idMenu button{ #idMenu button{
padding: 0.5em; padding: 0.5em;
} }
@ -89,8 +93,9 @@ $(document).ready(function() {
}) })
$('#idMenu-btnPrint').click(function() { $('#idMenu-btnPrint').click(function() {
if( BOB_var_printer.todos.indexOf(BOB_var_selectedBoothId) !== -1 ) {
if( confirm("Envoyer une demande d'impression du bobinogramme pour le livre d'Or?\n\nPour que tout le monde puisse mettre sa bobine, faites qu'une seul demande par groupe.") ) {
console.log(BOB_var_printer.todos, BOB_var_selectedBoothId)
if( BOB_var_printer.todos.indexOf(BOB_var_selectedBoothId) === -1 ) {
if( confirm("Envoyer une demande d'impression du bobinogramme pour le livre d'Or?\n\nPour que tout le monde puisse y mettre sa bobine, ne faites qu'une seule demande par groupe.") ) {
$.get("/print/bobinogramme/"+BOB_var_selectedBoothId, function(pResponse) { $.get("/print/bobinogramme/"+BOB_var_selectedBoothId, function(pResponse) {
if( pResponse.error ) { if( pResponse.error ) {
console.log("Printer: ", pResponse.error) console.log("Printer: ", pResponse.error)
@ -138,26 +143,11 @@ function BOB_getBooths() {
var jqBtnPrint = $('<button>'); var jqBtnPrint = $('<button>');
jqImg.css('width', '100%'); jqImg.css('width', '100%');
jqImg.css('opacity', '0'); jqImg.css('opacity', '0');
jqImg.css('display', 'block');
jqImg.css('position', 'relative');
jqImg.css('transition', 'opacity 1s'); jqImg.css('transition', 'opacity 1s');
jqImg.data('booth', pBoothName); jqImg.data('booth', pBoothName);
jqImg.attr('src', "/img/final_ld/"+pBoothName); jqImg.attr('src', "/img/final_ld/"+pBoothName);
jqImg.addClass('classBoothItem'); jqImg.addClass('classBoothItem');
jqBtnDownload.html("Télécharger");
jqBtnPrint.html("Imprimer");
jqMenu.css({
position: 'absolute',
top: 0,
left: 0,
width : "100%",
height : "100px"
})
jqMenu.append(jqBtnDownload);
jqMenu.append(jqBtnPrint);
jqImg.on('click', function() { jqImg.on('click', function() {
BOB_var_selectedBoothId = pBoothName; BOB_var_selectedBoothId = pBoothName;
$('#idMenu-preview').attr('src', "/img/final_ld/"+pBoothName); $('#idMenu-preview').attr('src', "/img/final_ld/"+pBoothName);
@ -172,8 +162,6 @@ function BOB_getBooths() {
BOB_var_lastBooth = pBoothName; BOB_var_lastBooth = pBoothName;
} }
jqImg.append(jqMenu);
jqBoothContainer.prepend(jqImg); jqBoothContainer.prepend(jqImg);
}) })
}) })

Loading…
Cancel
Save