if(Debug.debug) console.log("Loading: ArDetect"); // global-ish variables var _ard_oldAr; var _ard_currentAr; // kjer vzemamo vzorce za blackbox/stuff. 9 vzorcev. Če spremenimo velikost vzorca, moramo spremeniti tudi vrednosti v tej tabeli // vrednosti v tabeli so na osminskih intervalih od [0, - 4]. // we sample these lines in blackbox/stuff. 9 samples. If we change the canvas sample size, we have to correct these values as well // samples are every eighth between [0, - 4]. var _ard_sampleLines = [ 0, 360, 720, 1080, 1440, 1800, 2160, 2520, 2876] // **** FUNCTIONS **** // var _arSetup = function(){ var vid = document.getElementsByTagName("video")[0]; if(vid === undefined){ setTimeout(_arSetup, 1000); return; } // imamo video, pa tudi problem. Ta problem bo verjetno kmalu popravljen, zato setup začnemo hitreje kot prej // we have a video, but also a problem. This problem will prolly be fixed very soon, so setup is called with // less delay than before if(vid.videoWidth == 0){ setTimeout(_arSetup, 100); return; } var canvas = document.createElement("canvas"); canvas.style.position = "absolute"; //todo: change those values to push canvas off-screen if(Debug.showArDetectCanvas){ canvas.style.left = "200px"; canvas.style.top = "780px"; canvas.style.zIndex = 10000; } else{ canvas.style.left = "-20000px"; canvas.style.top = "-1080px"; canvas.style.zIndex = -10000; } canvas.id = "uw_ArDetect_canvas"; var test = document.getElementsByTagName("body")[0]; test.appendChild(canvas); var context = canvas.getContext("2d"); // do setup once // tho we could do it for every frame var canvasScaleFactor = 1280 / vid.videoWidth; var canvasWidth = vid.videoWidth * canvasScaleFactor; var canvasHeight = vid.videoHeight * canvasScaleFactor; console.log("canvasScaleFactor, vid.videoWidth: ", canvasScaleFactor, vid.videoWidth); canvas.width = canvasWidth; canvas.height = canvasHeight; // init oldAr to physical