Improved resolution and scaling of camera display
authorCedric Godin <cedric.godin@usherbrooke.ca>
Thu, 8 Feb 2018 16:17:36 +0000 (11:17 -0500)
committerCedric Godin <cedric.godin@usherbrooke.ca>
Thu, 8 Feb 2018 16:17:36 +0000 (11:17 -0500)
resources/js/point-to-image.js
resources/js/share-model.js
resources/js/tcp_link.js
views/share.html

index 72ffdbba2a44d39a151b31d6430c63aba846fbc3..a17b33bf9e4414b0f532b5103224ffb9a796df6a 100644 (file)
@@ -1,12 +1,12 @@
 math = require('mathjs');
 
 mtx = [
-    [  788.9292, 0, 329.4620],
-    [0, 785.3060, 229.3576],
+    [ 1389.6, 0,   995.9],
+    [0, 1387.2, 598.5],
     [0, 0, 1.0000]
 ];
 
-exports.transform = function(point) {
+exports.transform = function(point, scale) {
 
     pt = [
         -point.x,
@@ -16,5 +16,5 @@ exports.transform = function(point) {
 
     coord = math.multiply(mtx, pt);
 
-    return { x: coord[0], y: coord[1]};
+    return { x: coord[0]*scale, y: coord[1]*scale};
 }
index bf50be108d52b23e6b21bae7b76ed4a6bec157f9..cd9adc1091cd91983551bc6802d9d30cd2e1d89c 100644 (file)
@@ -10,7 +10,7 @@ var errorCallback = function(e) {
   };
 
   // Not showing vendor prefixes.
-  navigator.getUserMedia({video: true, audio: false}, function(localMediaStream) {
+  navigator.getUserMedia({video: { width: {min:1920}, height:{min:1080}}, audio: false}, function(localMediaStream) {
     var video = document.getElementById('video-frame')
     video.src = window.URL.createObjectURL(localMediaStream);
   }, errorCallback);
@@ -28,17 +28,19 @@ ipcRenderer.on('tracking', (event, data)=> {
                 z: source.z
             };
 
-            let coord = pointToImage.transform(point);
+            let video = document.getElementById('video-frame');
+
+            let scale = video.offsetWidth / 1920;
+            let coord = pointToImage.transform(point,scale);
 
             marker.style.top = coord.y-25 + 'px';
             marker.style.left = coord.x-25 + 'px';
-            let video = document.getElementById('video-frame');
 
             if(coord.y < 0 || coord.x < 0) {
                 marker.style.display = 'none';
             }
 
-            else if(coord.x > video.offsetWidth || coord.y > video.offsetHeight) {
+            else if(coord.x > 1920*scale || coord.y > 1080*scale) {
                 marker.style.display = 'none';
             }
 
index d6345a7fbe2df30812c5a3fb3810c1595205e927..99f6d5985206344f8ab3ba9d2b178a9b5410e2bd 100644 (file)
@@ -177,6 +177,7 @@ document.addEventListener('clearChart', function(e){
     currentFrame.potentialSources = [];
 
     document.dispatchEvent(new Event('tracking'));
+    ipcRenderer.send('tracking', currentFrame.sources);
     document.dispatchEvent(new Event('potential'));
     document.dispatchEvent(new Event('update-selection'));
 
index 1673754fb4b0555d69a3227995e0a17454198a82..826b846e5c31d91d39e299ea5b826ec33ca79658 100644 (file)
@@ -21,7 +21,7 @@
         <div id="share-model" class="container-fluid p-body">
             <div class="row">
                 <div class="col-sm-12">
-                        <video style="position:absolute; top:0px; left:0px; z-index:-10" id="video-frame" autoplay></video>
+                        <video style="position:absolute; top:0px; left:0px; z-index:-10; max-width:100vw; max-height:100vh; padding-bottom:80px"  id="video-frame" autoplay></video>
                         <canvas style="position:absolute; display:none" class="marker" ></canvas>
                         <canvas style="position:absolute; display:none" class="marker" ></canvas>
                         <canvas style="position:absolute; display:none" class="marker" ></canvas>