Last active
December 14, 2015 17:14
-
-
Save tako2/3b37548f7aa2ef1feac4 to your computer and use it in GitHub Desktop.
node.js script for taking picture with THETA S API. It needs request module.
This file contains 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
var request = require('request'); | |
var options = { | |
uri: 'http://192.168.1.1/osc/commands/execute', | |
headers: { 'Content-Type': 'application/json;charset=utf-8' }, | |
json: true, | |
keepAlive: false, | |
body: { "name": "camera.startSession" } | |
}; | |
request.post(options, function(err, res, body) { | |
if (err) { | |
console.log(err); | |
return; | |
} | |
if (res.statusCode == 200) { | |
// Session Starts | |
options.body = { | |
"name": "camera.takePicture", | |
"parameters": { | |
"sessionId": body.results.sessionId | |
} | |
}; | |
// Take Picture | |
request.post(options, function(err2, res2, body2) { | |
// Close Session | |
options.body.name = "camera.closeSession"; | |
request.post(options); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment