Created
November 24, 2021 23:39
-
-
Save OsvaldoFrias/d30bd23a72b0ed9581409a4ea4cc88ee to your computer and use it in GitHub Desktop.
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
var securos = require('securos'); | |
var express = require('express'); | |
var request = require('request'); | |
var app = express(); | |
var fs = require('fs'); | |
var url ="http://127.0.0.1:8096/securos_cam="; | |
var camid ="3"; | |
const picturesFolder = 'C://Users//ISS//Desktop//MBTA_Dataset'; | |
securos.connect(async function(core){ | |
core.registerEventHandler('MACRO','1.1',"RUN",macro) | |
}) | |
function macro(e){ | |
console.log('Macro Excecuted') | |
fs.readdir(picturesFolder,async (err, files) => { | |
for (const file of files) { | |
console.log(file); | |
console.log("Sending image to photo grabber "); | |
var options = { | |
'method': 'POST', | |
'url': url + camid + '&uploadfiles', | |
'headers': { | |
}, | |
formData: { | |
'': { | |
'value': fs.createReadStream(picturesFolder +'//'+ file), | |
'options': { | |
'filename': 'image.jpg', | |
'contentType': null | |
} | |
} | |
} | |
}; | |
request(options, function (error, response) { | |
if (error) throw new Error(error); | |
console.log(response.body); | |
}); | |
await sleep(2000); | |
} | |
}); | |
} | |
function sleep(ms) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, ms); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment