node-red-node-ui-webcam
Advanced tools
+1
-1
| { | ||
| "name": "node-red-node-ui-webcam", | ||
| "version": "0.3.0", | ||
| "version": "0.4.0", | ||
| "description": "A Node-RED ui node to capture images from a webcam.", | ||
@@ -5,0 +5,0 @@ "author": "Nick O'Leary", |
+4
-1
| node-red-node-ui-webcam | ||
| ============================ | ||
| ======================= | ||
@@ -24,2 +24,5 @@ A Node-RED UI widget node that allows images to be captured from the dashboard. | ||
| The user can select the default camera to use in the on-screen widget dropdown. | ||
| This will be used for future sessions with that browser until changed. | ||
| ## Browser Support | ||
@@ -26,0 +29,0 @@ |
+14
-10
@@ -39,3 +39,3 @@ <!-- | ||
| mirror: { value: true }, | ||
| format: { value:"png" } | ||
| format: { value: "png" } | ||
| }, | ||
@@ -125,7 +125,7 @@ inputs:1, | ||
| <br /> | ||
| <div class="form-row" style="min-width: 470px"> | ||
| <label style="vertical-align: top"><i class="fa fa-cog"></i> Options</label> | ||
| <div class="form-row" style="min-width:470px"> | ||
| <label style="vertical-align:top"><i class="fa fa-cog"></i> Options</label> | ||
| <div style="display:inline-block; min-width:350px; width:calc(100% - 120px);"> | ||
| <div class="form-row"> | ||
| <label style="width: auto" for="node-input-autoStart"> | ||
| <label style="width:auto" for="node-input-autoStart"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-autoStart"> Start webcam automatically | ||
@@ -135,3 +135,3 @@ </label> | ||
| <div class="form-row"> | ||
| <label style="width: auto" for="node-input-showImage-enable"> | ||
| <label style="width:auto" for="node-input-showImage-enable"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-showImage-enable"> Show image after capture | ||
@@ -141,3 +141,3 @@ </label> | ||
| <label style="margin-bottom:0; margin-left:20px; width:auto" for="node-input-showImage-timeout"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-showImage-timeout"> Clear image after <input style="width:60px; margin: 0" type="text" id="node-input-showImage-time"> seconds | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-showImage-timeout"> Clear image after <input style="width:60px; margin:0" type="text" id="node-input-showImage-time"> seconds | ||
| </label> | ||
@@ -147,3 +147,3 @@ </div> | ||
| <div class="form-row"> | ||
| <label style="width: auto" for="node-input-hideCaptureButton"> | ||
| <label style="width:auto" for="node-input-hideCaptureButton"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-hideCaptureButton"> Hide capture button | ||
@@ -153,3 +153,3 @@ </label> | ||
| <div class="form-row"> | ||
| <label style="width: auto" for="node-input-countdown"> | ||
| <label style="width:auto" for="node-input-countdown"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-countdown"> Use 5 second countdown when triggered | ||
@@ -159,3 +159,3 @@ </label> | ||
| <div class="form-row"> | ||
| <label style="width: auto" for="node-input-mirror"> | ||
| <label style="width:auto" for="node-input-mirror"> | ||
| <input style="width:auto; margin:0" type="checkbox" id="node-input-mirror"> Mirror image from webcam | ||
@@ -191,2 +191,4 @@ </label> | ||
| have been activated on the dashboard first.</dd> | ||
| <dt>camera<span class="property-type">Number</span></dt> | ||
| <dd>If set to a number that is the index of an available camera, the stream will switch to that camera.</dd> | ||
| </dl> | ||
@@ -196,6 +198,8 @@ <h3>Outputs</h3> | ||
| <dt>payload<span class="property-type">Buffer</span></dt> | ||
| <dd>The captured image as a png or jpeg.</dd> | ||
| <dd>The captured image as a png or jpeg. Most image recognition processes prefer jpeg.</dd> | ||
| </dl> | ||
| <h3>Details</h3> | ||
| The user may set the preferred camera from a dropdown in the on-screen widget. | ||
| This will be used by default for future sessions. | ||
| <p></p> | ||
| </script> |
+20
-6
@@ -224,2 +224,3 @@ /** | ||
| activeCamera = $scope.data.cameras[deviceId].deviceId; | ||
| window.localStorage.setItem("node-red-node-ui-webcam-activeCam",deviceId); | ||
| $scope.disableCamera(); | ||
@@ -279,3 +280,6 @@ $scope.enableCamera(); | ||
| if (activeCamera === null) { | ||
| activeCamera = stream.getTracks()[0].getSettings().deviceId; | ||
| var cam = parseInt(window.localStorage.getItem("node-red-node-ui-webcam-activeCam") || 0); | ||
| if (cam < stream.getTracks().length) { | ||
| activeCamera = stream.getTracks()[cam].getSettings().deviceId; | ||
| } | ||
| } | ||
@@ -382,8 +386,18 @@ }).catch(handleError); | ||
| $scope.$watch('msg', function(msg) { | ||
| if (!msg) { | ||
| return; | ||
| if (!msg) { return; } | ||
| if (msg.camera !== undefined) { | ||
| if (!isNaN(parseInt(msg.camera))) { | ||
| var c = parseInt(msg.camera); | ||
| if (c >= 0 || c < 16) { | ||
| oldActiveCamera = activeCamera; | ||
| $scope.disableCamera(); | ||
| activeCamera = null; | ||
| window.localStorage.setItem("node-red-node-ui-webcam-activeCam",c); | ||
| if (active !== false) { | ||
| $scope.enableCamera(); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (!active) { | ||
| return; | ||
| } | ||
| if (!active) { return; } | ||
| var img = document.querySelector("img#ui_webcam_image_"+$scope.$id); | ||
@@ -390,0 +404,0 @@ if (msg.capture) { |
42985
3.82%408
3.55%39
8.33%