Last active
August 29, 2015 14:25
-
-
Save pdp7/5f877c01d5b4853e0061 to your computer and use it in GitHub Desktop.
geocahe: changes to shmile/lib/camera_control.coffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/app.coffee b/app.coffee | |
| index 3138226..63e5333 100644 | |
| --- a/app.coffee | |
| +++ b/app.coffee | |
| @@ -47,7 +47,7 @@ camera.on "photo_saved", (filename, path, web_url) -> | |
| State.image_src_list.push path | |
| io = require("socket.io").listen(web) | |
| -web.listen 3000 | |
| +web.listen 3001 | |
| io.sockets.on "connection", (websocket) -> | |
| sys.puts "Web browser connected" | |
| diff --git a/lib/camera_control.coffee b/lib/camera_control.coffee | |
| index 30ad366..1900d8b 100644 | |
| --- a/lib/camera_control.coffee | |
| +++ b/lib/camera_control.coffee | |
| @@ -10,8 +10,9 @@ exec = require("child_process").exec | |
| # guest... | |
| ### | |
| class CameraControl | |
| - saving_regex: /Saving file as ([^.jpg]+)/g | |
| - captured_success_regex: /New file is in/g | |
| + # geocache: this is messages fswebcam uses [afustini] | |
| + saving_regex: /Writing JPEG image to ([^.jpg]+)/g | |
| + captured_success_regex: /Processing captured image/g | |
| constructor: ( | |
| @filename="%m-%y-%d_%H:%M:%S.jpg", | |
| @@ -19,30 +20,25 @@ class CameraControl | |
| @web_root_path="/photos") -> | |
| init: -> | |
| - exec "killall PTPCamera" | |
| + # geocache: not using gphoto or PTP | |
| + #exec "killall PTPCamera" | |
| emitter = new EventEmitter() | |
| emitter.on "snap", (onCaptureSuccess, onSaveSuccess) => | |
| emitter.emit "camera_begin_snap" | |
| - capture = spawn("gphoto2", [ "--capture-image-and-download", | |
| - "--force-overwrite", | |
| - "--filename=" + @filename ], | |
| - cwd: @cwd | |
| - ) | |
| - capture.stdout.on "data", (data) => | |
| - if @captured_success_regex.exec(data.toString()) | |
| - emitter.emit "camera_snapped" | |
| - onCaptureSuccess() if onCaptureSuccess? | |
| - | |
| - saving = @saving_regex.exec(data.toString()) | |
| - if saving | |
| - fname = saving[1] + ".jpg" | |
| - emitter.emit( | |
| + # geocache: change to fswebcam [afustini] | |
| + @filename=(new Date).getTime() + ".jpg"; | |
| + console.log('capture: @filename=' + @filename); | |
| + capture = spawn("/home/debian/snapshot-fsw.sh", [ @filename ], cwd: @cwd) | |
| + emitter.emit "camera_snapped" | |
| + onCaptureSuccess() if onCaptureSuccess? | |
| + fname = @filename | |
| + emitter.emit( | |
| "photo_saved", | |
| fname, | |
| @cwd + "/" + fname, | |
| @web_root_path + "/" + fname | |
| - ) | |
| - onSaveSuccess() if onSaveSuccess? | |
| + ) | |
| + onSaveSuccess() if onSaveSuccess? | |
| emitter | |
| module.exports = CameraControl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment