@intres/azure-computer-vision
Version:
Node-red nodes for Microsoft Azure Computer Vision
108 lines (98 loc) • 4.42 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('img-obj-detect',{
category: 'Azure Computer Vision',
color: '#008AD7',
defaults: {
name: { value: '' },
inputMode: { value: 'url', required: true },
imageFilePath: { value: '', validate: function() {
// If input mode is file, imageFilePath is required
if (this.inputMode === 'file') return !!this.imageFilePath;
return true;
}},
imageUrl: { value: '', validate: function() {
// If input mode is url, imageUrl is required
if (this.inputMode === 'url') return !!this.imageUrl;
return true;
}},
modelVersion: {value: ''}
},
credentials: {
key: { type: 'password' },
region: { type: 'text' }
},
inputs: 1,
outputs: 1,
label: function() {
if (this.name) return this.name;
return 'ms-img-obj-detect';
},
oneditprepare: function() {
$('#node-input-inputMode').on('change', function() {
if (this.value === 'url') {
$('#node-input-div-imageFilePath').hide();
$('#node-input-div-imageUrl').show();
} else {
$('#node-input-div-imageFilePath').show();
$('#node-input-div-imageUrl').hide();
}
});
},
icon: 'font-awesome/fa-exchange',
});
</script>
<script type="text/html" data-template-name="img-obj-detect">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name </label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-inputMode"><i class="fa fa-tag"></i> Input mode </label>
<select name="node-input-inputMode" id="node-input-inputMode">
<option value="file"> file </option>
<option value="url"> url </option>
</select>
</div>
<div id="node-input-div-imageFilePath" class="form-row">
<label for="node-input-imageFilePath"><i class="fa fa-tag"></i> Image file path </label>
<input type="text" id="node-input-imageFilePath" placeholder="Must be an absolute path to local file system">
</div>
<div id="node-input-div-imageUrl" class="form-row">
<label for="node-input-imageUrl"><i class="fa fa-tag"></i> Image url </label>
<input type="text" id="node-input-imageUrl" placeholder="URL to the image">
</div>
<div id="node-input-div-modelVersion" class="form-row">
<label for="node-input-modelVersion"><i class="fa fa-tag"></i> Model version </label>
<input type="text" id="node-input-modelVersion" placeholder="Optional parameter to specify the version of the AI model">
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-tag"></i> Key </label>
<input type="password" id="node-input-key" placeholder="Your beautiful key">
</div>
<div class="form-row">
<label for="node-input-region"><i class="fa fa-tag"></i> Region </label>
<input type="text" id="node-input-region" placeholder="Region">
</div>
</script>
<script type="text/html" data-help-name="img-obj-detect">
<p> Image objects detect of Microsoft Computer Vision </p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt> msg.payload
<span class="property-type"> Object </span>
</dt>
<dd>
For more information about output, please refer to the <a href="https://westus.dev.cognitive.microsoft.com/docs/services/computer-vision-v3-2/operations/56f91f2e778daf14a499f21b">official document</a>.
</dd>
</dl>
<h3>Details</h3>
<p>
There are two input modes for this node: file mode and url mode.
</p>
<h5> 'file' mode </h5>
<p> In file mode, the node will try to read image content to be analyzed from the file path given.
</p>
<h5> 'url' mode </h5>
<p> In url mode, the node will try to read image content to be analyzed from url provided. </p>
<p> modelVersion is an optional input to specify the version of the AI model. The default value is "latest".</p>
</script>