Guest User

Untitled

a guest
May 27th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var wia = require('wia')('your-device-secret-key');
  4. var fs = require('fs');
  5. var RaspiCam = require("raspicam");
  6.  
  7. // Setup the camera
  8. var camera = new RaspiCam({
  9. mode: 'photo',
  10. output: __dirname + '/photo.jpg',
  11. encoding: 'jpg'
  12. });
  13.  
  14. // Listen for the "start" event triggered when the start method has been successfully initiated
  15. camera.on("start", function(){
  16. console.log("Starting to take photo.");
  17. });
  18.  
  19. // Listen for the "read" event triggered when each new photo/video is saved
  20. camera.on("read", function(err, timestamp, filename){
  21. console.log("New photo created.", timestamp, filename);
  22.  
  23. // Publish the photo to Wia
  24. wia.events.publish({
  25. name: 'photo',
  26. file: fs.createReadStream(__dirname + '/' + filename)
  27. });
  28. });
  29.  
  30. // Take a photo
  31. camera.start();
Add Comment
Please, Sign In to add comment