Skip to content

Commit fb716fd

Browse files
author
Dave Conway-Jones
committed
Flip wecam left-right to behave like mirrow
much more natural
1 parent a4267f5 commit fb716fd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

node-red-node-ui-webcam/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-ui-webcam",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A Node-RED ui node to capture images from a webcam.",
55
"author": "Nick O'Leary",
66
"license": "Apache-2.0",

node-red-node-ui-webcam/ui_webcam.html

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
category: 'dashboard',
1717
color: 'rgb( 63, 173, 181)',
1818
defaults: {
19+
name: {value: ''},
1920
group: {type: 'ui_group', required:true},
2021
order: {value: 0},
2122
width: {
@@ -29,8 +30,7 @@
2930
$("#node-input-size").toggleClass("input-error",!valid);
3031
return valid;
3132
}},
32-
height: {value: 0},
33-
name: {value: ''},
33+
height: {value: 5},
3434
countdown: { value: false },
3535
autoStart: { value: false },
3636
hideCaptureButton: { value: false },
@@ -87,7 +87,6 @@
8787
})
8888

8989
$("#node-input-showImage-enable").trigger("change");
90-
9190
},
9291
oneditsave: function() {
9392
var showImageEnable = $("#node-input-showImage-enable")[0].checked;
@@ -101,7 +100,6 @@
101100
} else {
102101
this.showImage = showImageTime;
103102
}
104-
105103
}
106104
});
107105
</script>
@@ -154,7 +152,6 @@
154152
</select>
155153
</div>
156154
</div>
157-
158155
</div>
159156
<div class="form-row">
160157
<label for="node-input-name"><i class="icon-tag"></i> Name</label>

node-red-node-ui-webcam/ui_webcam.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = function(RED) {
4242
position: absolute;
4343
width: 100%;
4444
height: 100%;
45+
-webkit-transform: scaleX(-1);
46+
transform: scaleX(-1);
4547
}
4648
.ui-webcam-playback-container {
4749
width: 100%;
@@ -211,8 +213,6 @@ module.exports = function(RED) {
211213
var activeCamera = null;
212214
var oldActiveCamera = null;
213215

214-
215-
216216
$scope.changeCamera = function(deviceId) {
217217
oldActiveCamera = activeCamera;
218218
activeCamera = $scope.data.cameras[deviceId].deviceId;
@@ -325,7 +325,10 @@ module.exports = function(RED) {
325325
var canvas = document.querySelector("canvas#ui_webcam_canvas_"+$scope.$id);
326326
canvas.width = playbackEl.videoWidth;
327327
canvas.height = playbackEl.videoHeight;
328-
canvas.getContext('2d').drawImage(playbackEl, 0, 0);
328+
var ctx = canvas.getContext('2d');
329+
ctx.translate(playbackEl.videoWidth, 0);
330+
ctx.scale(-1, 1);
331+
ctx.drawImage(playbackEl, 0, 0);
329332
var img = document.querySelector("img#ui_webcam_image_"+$scope.$id);
330333
img.src = canvas.toDataURL('image/'+($scope.config.format||'png'));
331334
if ($scope.config.showImage) {

0 commit comments

Comments
 (0)