Skip to content

Instantly share code, notes, and snippets.

@tako2
Last active December 14, 2015 17:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tako2/3b37548f7aa2ef1feac4 to your computer and use it in GitHub Desktop.
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.
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