@intres/azure-computer-vision
Version:
Node-red nodes for Microsoft Azure Computer Vision
36 lines (31 loc) • 1.21 kB
JavaScript
const ImageAnalysisGetInterest = require('./image-analysis-get-interest');
module.exports = function(RED) {
function translation(config) {
RED.nodes.createNode(this, config);
this.on('input', async (msg) => {
try {
const options = {
inputMode: config.inputMode,
imageFilePath: config.imageFilePath,
imageUrl: config.imageUrl,
modelVersion: config.modelVersion || 'latest',
};
const driver = new ImageAnalysisGetInterest(this, this.credentials.key, this.credentials.region);
const res = await driver.run(options);
this.status({});
this.send({ payload: res });
} catch (e) {
// Clear status in the node
this.status({});
// Send error to catch node, original msg object must be provided
this.error(e.message, msg);
}
});
}
RED.nodes.registerType("area-of-interest", translation, {
credentials: {
key: { type: 'password' },
region: { type: 'text' }
},
});
}