From 09556d7172e17870993402bf36d1cda89561a536 Mon Sep 17 00:00:00 2001 From: Cedric Godin Date: Thu, 8 Feb 2018 11:17:36 -0500 Subject: [PATCH] Improved resolution and scaling of camera display --- resources/js/point-to-image.js | 8 ++++---- resources/js/share-model.js | 10 ++++++---- resources/js/tcp_link.js | 1 + views/share.html | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/resources/js/point-to-image.js b/resources/js/point-to-image.js index 72ffdbb..a17b33b 100644 --- a/resources/js/point-to-image.js +++ b/resources/js/point-to-image.js @@ -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}; } diff --git a/resources/js/share-model.js b/resources/js/share-model.js index bf50be1..cd9adc1 100644 --- a/resources/js/share-model.js +++ b/resources/js/share-model.js @@ -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'; } diff --git a/resources/js/tcp_link.js b/resources/js/tcp_link.js index d6345a7..99f6d59 100644 --- a/resources/js/tcp_link.js +++ b/resources/js/tcp_link.js @@ -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')); diff --git a/views/share.html b/views/share.html index 1673754..826b846 100644 --- a/views/share.html +++ b/views/share.html @@ -21,7 +21,7 @@
- + -- 2.34.1