fix find/replace gone wrong

This commit is contained in:
Tamius Han 2020-05-26 23:51:00 +02:00
parent 3eeef5410f
commit 8d6367d16c
3 changed files with 60 additions and 60 deletions

View File

@ -30,7 +30,7 @@ class AardGl {
this.canFallback = true; this.canFallback = true;
this.fallbackMode = false; this.fallbackMode = false;
this.blackLevel = this.settings.activeaard.blackbar.blackLevel; this.blackLevel = this.settings.active.aard.blackbar.blackLevel;
this.arid = (Math.random()*100).toFixed(); this.arid = (Math.random()*100).toFixed();
@ -61,15 +61,15 @@ class AardGl {
// we slow down if ended or pausing. Detecting is pointless. // we slow down if ended or pausing. Detecting is pointless.
// we don't stop outright in case seeking happens during pause/after video was // we don't stop outright in case seeking happens during pause/after video was
// ended and video gets into 'playing' state again // ended and video gets into 'playing' state again
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.paused; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.paused;
} }
if (this.video.error){ if (this.video.error){
// če je video pavziran, še vedno skušamo zaznati razmerje stranic - ampak bolj poredko. // če je video pavziran, še vedno skušamo zaznati razmerje stranic - ampak bolj poredko.
// if the video is paused, we still do autodetection. We just do it less often. // if the video is paused, we still do autodetection. We just do it less often.
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.error; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.error;
} }
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.playing; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.playing;
} }
isRunning(){ isRunning(){
@ -114,7 +114,7 @@ class AardGl {
} }
resetBlackLevel(){ resetBlackLevel(){
this.blackLevel = this.settings.activeaard.blackbar.blackLevel; this.blackLevel = this.settings.active.aard.blackbar.blackLevel;
} }
clearImageData(id) { clearImageData(id) {
@ -307,8 +307,8 @@ class AardGl {
// //
if (!cwidth) { if (!cwidth) {
cwidth = this.settings.activeaard.Gl.canvasDimensions.sampleCanvas.width; cwidth = this.settings.active.aard.Gl.canvasDimensions.sampleCanvas.width;
cheight = this.settings.activeaard.Gl.canvasDimensions.sampleCanvas.height; cheight = this.settings.active.aard.Gl.canvasDimensions.sampleCanvas.height;
} }
if (this.canvas) { if (this.canvas) {
@ -323,8 +323,8 @@ class AardGl {
this.canvas.width = cwidth; this.canvas.width = cwidth;
this.canvas.height = cheight; this.canvas.height = cheight;
this.blackframeCanvas = document.createElement("canvas"); this.blackframeCanvas = document.createElement("canvas");
this.blackframeCanvas.width = this.settings.activeaard.canvasDimensions.blackframeCanvas.width; this.blackframeCanvas.width = this.settings.active.aard.canvasDimensions.blackframeCanvas.width;
this.blackframeCanvas.height = this.settings.activeaard.canvasDimensions.blackframeCanvas.height; this.blackframeCanvas.height = this.settings.active.aard.canvasDimensions.blackframeCanvas.height;
// this.context = this.canvas.getContext("2d"); // this.context = this.canvas.getContext("2d");
@ -368,7 +368,7 @@ class AardGl {
// we need a rectangle. This is output data, not texture. This means that the size of the rectangle should be // we need a rectangle. This is output data, not texture. This means that the size of the rectangle should be
// [sample count] x height of the sample, as shader can sample frame at a different resolution than what gets // [sample count] x height of the sample, as shader can sample frame at a different resolution than what gets
// rendered here. We don't need all horizontal pixels on our output. We do need all vertical pixels, though) // rendered here. We don't need all horizontal pixels on our output. We do need all vertical pixels, though)
this.glSetRectangle(this.gl, this.settings.activeaard..sampleCols, cheight); this.glSetRectangle(this.gl, this.settings.active.aard.sampleCols, cheight);
// do setup once // do setup once
// tho we could do it for every frame // tho we could do it for every frame
@ -458,7 +458,7 @@ class AardGl {
while (!this._exited && exitedRetries --> 0) { while (!this._exited && exitedRetries --> 0) {
this.logger.log('warn', 'debug', `[AardGl::main] <@${this.arid}> We are trying to start another instance of autodetection on current video, but the previous instance hasn't exited yet. Waiting for old instance to exit ...`); this.logger.log('warn', 'debug', `[AardGl::main] <@${this.arid}> We are trying to start another instance of autodetection on current video, but the previous instance hasn't exited yet. Waiting for old instance to exit ...`);
await sleep(this.settings.activeaard.timers.tickrate); await sleep(this.settings.active.aard.timers.tickrate);
} }
if (!this._exited) { if (!this._exited) {
this.logger.log('error', 'debug', `[AardGl::main] <@${this.arid}> Previous instance didn't exit in time. Not starting a new one.`); this.logger.log('error', 'debug', `[AardGl::main] <@${this.arid}> Previous instance didn't exit in time. Not starting a new one.`);
@ -472,7 +472,7 @@ class AardGl {
this._exited = false; this._exited = false;
// set initial timestamps so frame check will trigger the first time we run the loop // set initial timestamps so frame check will trigger the first time we run the loop
let lastFrameCheckStartTime = Date.now() - (this.settings.activeaard.Gl.timers.playing << 1); let lastFrameCheckStartTime = Date.now() - (this.settings.active.aard.Gl.timers.playing << 1);
const frameCheckTimes = new Array(10).fill(-1); const frameCheckTimes = new Array(10).fill(-1);
let frameCheckBufferIndex = 0; let frameCheckBufferIndex = 0;
@ -600,7 +600,7 @@ class AardGl {
var trueHeight = this.canvas.height * zoomFactor - letterbox; var trueHeight = this.canvas.height * zoomFactor - letterbox;
if(edges.top > 1 && edges.top <= this.settings.activeaard.fallbackMode.noTriggerZonePx ){ if(edges.top > 1 && edges.top <= this.settings.active.aard.fallbackMode.noTriggerZonePx ){
this.logger.log('info', 'arDetect', `%c[AardGl::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`) this.logger.log('info', 'arDetect', `%c[AardGl::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`)
return; return;
} }
@ -609,7 +609,7 @@ class AardGl {
// x2, ker je safetyBorderPx definiran za eno stran. // x2, ker je safetyBorderPx definiran za eno stran.
// safety border so we can detect aspect ratio narrowing (21:9 -> 16:9). // safety border so we can detect aspect ratio narrowing (21:9 -> 16:9).
// x2 because safetyBorderPx is for one side. // x2 because safetyBorderPx is for one side.
trueHeight += (this.settings.activeaard.fallbackMode.safetyBorderPx << 1); trueHeight += (this.settings.active.aard.fallbackMode.safetyBorderPx << 1);
return this.canvas.width * zoomFactor / trueHeight; return this.canvas.width * zoomFactor / trueHeight;
} }
@ -638,7 +638,7 @@ class AardGl {
// is ar variance within acceptable levels? If yes -> we done // is ar variance within acceptable levels? If yes -> we done
this.logger.log('info', 'arDetect', `%c[AardGl::processAr] <@${this.arid}> New aspect ratio varies from the old one by this much:\n`,"color: #aaf","old Ar", lastAr.ar, "current ar", trueAr, "arDiff (absolute):",arDiff,"ar diff (relative to new ar)", arDiff_percent); this.logger.log('info', 'arDetect', `%c[AardGl::processAr] <@${this.arid}> New aspect ratio varies from the old one by this much:\n`,"color: #aaf","old Ar", lastAr.ar, "current ar", trueAr, "arDiff (absolute):",arDiff,"ar diff (relative to new ar)", arDiff_percent);
if (arDiff < trueAr * this.settings.activeaard.allowedArVariance){ if (arDiff < trueAr * this.settings.active.aard.allowedArVariance){
this.logger.log('info', 'arDetect', `%c[AardGl::processAr] <@${this.arid}> Aspect ratio change denied — diff %: ${arDiff_percent}`, "background: #740; color: #fa2"); this.logger.log('info', 'arDetect', `%c[AardGl::processAr] <@${this.arid}> Aspect ratio change denied — diff %: ${arDiff_percent}`, "background: #740; color: #fa2");
return; return;
} }

View File

@ -25,7 +25,7 @@ class ArDetector {
this.canFallback = true; this.canFallback = true;
this.fallbackMode = false; this.fallbackMode = false;
this.blackLevel = this.settings.activeaard.blackbar.blackLevel; this.blackLevel = this.settings.active.aard.blackbar.blackLevel;
this.arid = (Math.random()*100).toFixed(); this.arid = (Math.random()*100).toFixed();
@ -97,8 +97,8 @@ class ArDetector {
// //
if (!cwidth) { if (!cwidth) {
cwidth = this.settings.activeaard.canvasDimensions.sampleCanvas.width; cwidth = this.settings.active.aard.canvasDimensions.sampleCanvas.width;
cheight = this.settings.activeaard.canvasDimensions.sampleCanvas.height; cheight = this.settings.active.aard.canvasDimensions.sampleCanvas.height;
} }
if (this.canvas) { if (this.canvas) {
@ -113,8 +113,8 @@ class ArDetector {
this.canvas.width = cwidth; this.canvas.width = cwidth;
this.canvas.height = cheight; this.canvas.height = cheight;
this.blackframeCanvas = document.createElement("canvas"); this.blackframeCanvas = document.createElement("canvas");
this.blackframeCanvas.width = this.settings.activeaard.canvasDimensions.blackframeCanvas.width; this.blackframeCanvas.width = this.settings.active.aard.canvasDimensions.blackframeCanvas.width;
this.blackframeCanvas.height = this.settings.activeaard.canvasDimensions.blackframeCanvas.height; this.blackframeCanvas.height = this.settings.active.aard.canvasDimensions.blackframeCanvas.height;
this.context = this.canvas.getContext("2d"); this.context = this.canvas.getContext("2d");
this.blackframeContext = this.blackframeCanvas.getContext("2d"); this.blackframeContext = this.blackframeCanvas.getContext("2d");
@ -129,8 +129,8 @@ class ArDetector {
// [2] determine places we'll use to sample our main frame // [2] determine places we'll use to sample our main frame
// //
var ncol = this.settings.activeaard.sampling.staticCols; var ncol = this.settings.active.aard.sampling.staticCols;
var nrow = this.settings.activeaard.sampling.staticRows; var nrow = this.settings.active.aard.sampling.staticRows;
var colSpacing = this.canvas.width / ncol; var colSpacing = this.canvas.width / ncol;
var rowSpacing = (this.canvas.height << 2) / nrow; var rowSpacing = (this.canvas.height << 2) / nrow;
@ -258,7 +258,7 @@ class ArDetector {
while (!this._exited && exitedRetries --> 0) { while (!this._exited && exitedRetries --> 0) {
this.logger.log('warn', 'debug', `[ArDetect::main] <@${this.arid}> We are trying to start another instance of autodetection on current video, but the previous instance hasn't exited yet. Waiting for old instance to exit ...`); this.logger.log('warn', 'debug', `[ArDetect::main] <@${this.arid}> We are trying to start another instance of autodetection on current video, but the previous instance hasn't exited yet. Waiting for old instance to exit ...`);
await sleep(this.settings.activeaard.timers.tickrate); await sleep(this.settings.active.aard.timers.tickrate);
} }
if (!this._exited) { if (!this._exited) {
this.logger.log('error', 'debug', `[ArDetect::main] <@${this.arid}> Previous instance didn't exit in time. Not starting a new one.`); this.logger.log('error', 'debug', `[ArDetect::main] <@${this.arid}> Previous instance didn't exit in time. Not starting a new one.`);
@ -272,7 +272,7 @@ class ArDetector {
this._exited = false; this._exited = false;
// set initial timestamps so frame check will trigger the first time we run the loop // set initial timestamps so frame check will trigger the first time we run the loop
let lastFrameCheckStartTime = Date.now() - (this.settings.activeaard.timers.playing << 1); let lastFrameCheckStartTime = Date.now() - (this.settings.active.aard.timers.playing << 1);
const frameCheckTimes = new Array(10).fill(-1); const frameCheckTimes = new Array(10).fill(-1);
let frameCheckBufferIndex = 0; let frameCheckBufferIndex = 0;
@ -303,7 +303,7 @@ class ArDetector {
} }
} }
await sleep(this.settings.activeaard.timers.tickrate); await sleep(this.settings.active.aard.timers.tickrate);
} }
this.logger.log('info', 'debug', `%c[ArDetect::main] <@${this.arid}> Main autodetection loop exited. Halted? ${this._halted}`, _ard_console_stop); this.logger.log('info', 'debug', `%c[ArDetect::main] <@${this.arid}> Main autodetection loop exited. Halted? ${this._halted}`, _ard_console_stop);
@ -319,15 +319,15 @@ class ArDetector {
// we slow down if ended or pausing. Detecting is pointless. // we slow down if ended or pausing. Detecting is pointless.
// we don't stop outright in case seeking happens during pause/after video was // we don't stop outright in case seeking happens during pause/after video was
// ended and video gets into 'playing' state again // ended and video gets into 'playing' state again
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.paused; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.paused;
} }
if (this.video.error){ if (this.video.error){
// če je video pavziran, še vedno skušamo zaznati razmerje stranic - ampak bolj poredko. // če je video pavziran, še vedno skušamo zaznati razmerje stranic - ampak bolj poredko.
// if the video is paused, we still do autodetection. We just do it less often. // if the video is paused, we still do autodetection. We just do it less often.
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.error; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.error;
} }
return Date.now() - lastFrameCheckStartTime > this.settings.activeaard.timers.playing; return Date.now() - lastFrameCheckStartTime > this.settings.active.aard.timers.playing;
} }
isRunning(){ isRunning(){
@ -445,7 +445,7 @@ class ArDetector {
var trueHeight = this.canvas.height * zoomFactor - letterbox; var trueHeight = this.canvas.height * zoomFactor - letterbox;
if(edges.top > 1 && edges.top <= this.settings.activeaard.fallbackMode.noTriggerZonePx ){ if(edges.top > 1 && edges.top <= this.settings.active.aard.fallbackMode.noTriggerZonePx ){
this.logger.log('info', 'arDetect', `%c[ArDetect::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`) this.logger.log('info', 'arDetect', `%c[ArDetect::calculateArFromEdges] <@${this.arid}> Edge is in the no-trigger zone. Aspect ratio change is not triggered.`)
return; return;
} }
@ -454,7 +454,7 @@ class ArDetector {
// x2, ker je safetyBorderPx definiran za eno stran. // x2, ker je safetyBorderPx definiran za eno stran.
// safety border so we can detect aspect ratio narrowing (21:9 -> 16:9). // safety border so we can detect aspect ratio narrowing (21:9 -> 16:9).
// x2 because safetyBorderPx is for one side. // x2 because safetyBorderPx is for one side.
trueHeight += (this.settings.activeaard.fallbackMode.safetyBorderPx << 1); trueHeight += (this.settings.active.aard.fallbackMode.safetyBorderPx << 1);
return this.canvas.width * zoomFactor / trueHeight; return this.canvas.width * zoomFactor / trueHeight;
} }
@ -483,7 +483,7 @@ class ArDetector {
// is ar variance within acceptable levels? If yes -> we done // is ar variance within acceptable levels? If yes -> we done
this.logger.log('info', 'arDetect', `%c[ArDetect::processAr] <@${this.arid}> New aspect ratio varies from the old one by this much:\n`,"color: #aaf","old Ar", lastAr.ar, "current ar", trueAr, "arDiff (absolute):",arDiff,"ar diff (relative to new ar)", arDiff_percent); this.logger.log('info', 'arDetect', `%c[ArDetect::processAr] <@${this.arid}> New aspect ratio varies from the old one by this much:\n`,"color: #aaf","old Ar", lastAr.ar, "current ar", trueAr, "arDiff (absolute):",arDiff,"ar diff (relative to new ar)", arDiff_percent);
if (arDiff < trueAr * this.settings.activeaard.allowedArVariance){ if (arDiff < trueAr * this.settings.active.aard.allowedArVariance){
this.logger.log('info', 'arDetect', `%c[ArDetect::processAr] <@${this.arid}> Aspect ratio change denied — diff %: ${arDiff_percent}`, "background: #740; color: #fa2"); this.logger.log('info', 'arDetect', `%c[ArDetect::processAr] <@${this.arid}> Aspect ratio change denied — diff %: ${arDiff_percent}`, "background: #740; color: #fa2");
return; return;
} }
@ -698,11 +698,11 @@ class ArDetector {
} else { } else {
if (this.conf.player.dimensions){ if (this.conf.player.dimensions){
this.guardLine.setBlackbarManual({ this.guardLine.setBlackbarManual({
top: this.settings.activeaard.fallbackMode.noTriggerZonePx, top: this.settings.active.aard.fallbackMode.noTriggerZonePx,
bottom: this.conf.player.dimensions.height - this.settings.activeaard.fallbackMode.noTriggerZonePx - 1 bottom: this.conf.player.dimensions.height - this.settings.active.aard.fallbackMode.noTriggerZonePx - 1
},{ },{
top: edgePost.guardLineTop + this.settings.activeaard.guardLine.edgeTolerancePx, top: edgePost.guardLineTop + this.settings.active.aard.guardLine.edgeTolerancePx,
bottom: edgePost.guardLineBottom - this.settings.activeaard.guardLine.edgeTolerancePx bottom: edgePost.guardLineBottom - this.settings.active.aard.guardLine.edgeTolerancePx
}) })
} }
} }
@ -724,7 +724,7 @@ class ArDetector {
} }
resetBlackLevel(){ resetBlackLevel(){
this.blackLevel = this.settings.activeaard.blackbar.blackLevel; this.blackLevel = this.settings.active.aard.blackbar.blackLevel;
} }
blackLevelTest_full() { blackLevelTest_full() {
@ -749,7 +749,7 @@ class ArDetector {
let cumulativeValue = 0; let cumulativeValue = 0;
let blackPixelCount = 0; let blackPixelCount = 0;
const bfImageData = this.blackframeContext.getImageData(0, 0, cols, rows).data; const bfImageData = this.blackframeContext.getImageData(0, 0, cols, rows).data;
const blackTreshold = this.blackLevel + this.settings.activeaard.blackbar.frameTreshold; const blackTreshold = this.blackLevel + this.settings.active.aard.blackbar.frameTreshold;
// we do some recon for letterbox and pillarbox. While this can't determine whether letterbox/pillarbox exists // we do some recon for letterbox and pillarbox. While this can't determine whether letterbox/pillarbox exists
@ -810,17 +810,17 @@ class ArDetector {
} }
} }
const hasSufficientVariance = Math.abs(var_r - var_g) / Math.max(var_r, var_g, 1) > this.settings.activeaard.blackframe.sufficientColorVariance const hasSufficientVariance = Math.abs(var_r - var_g) / Math.max(var_r, var_g, 1) > this.settings.active.aard.blackframe.sufficientColorVariance
|| Math.abs(var_r - var_b) / Math.max(var_r, var_b, 1) > this.settings.activeaard.blackframe.sufficientColorVariance || Math.abs(var_r - var_b) / Math.max(var_r, var_b, 1) > this.settings.active.aard.blackframe.sufficientColorVariance
|| Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1) > this.settings.activeaard.blackframe.sufficientColorVariance || Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1) > this.settings.active.aard.blackframe.sufficientColorVariance
let isBlack = (blackPixelCount/(cols * rows) > this.settings.activeaard.blackframe.blackPixelsCondition); let isBlack = (blackPixelCount/(cols * rows) > this.settings.active.aard.blackframe.blackPixelsCondition);
if (! isBlack) { if (! isBlack) {
if (hasSufficientVariance) { if (hasSufficientVariance) {
isBlack = cumulativeValue < this.settings.activeaard.blackframe.cumulativeThresholdLax; isBlack = cumulativeValue < this.settings.active.aard.blackframe.cumulativeThresholdLax;
} else { } else {
isBlack = cumulativeValue < this.settings.activeaard.blackframe.cumulativeThresholdStrict; isBlack = cumulativeValue < this.settings.active.aard.blackframe.cumulativeThresholdStrict;
} }
} }
@ -842,13 +842,13 @@ class ArDetector {
gb: Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1), gb: Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1),
}, },
relativePercent: { relativePercent: {
rg: Math.abs(var_r - var_g) / Math.max(var_r, var_g, 1) / this.settings.activeaard.blackframe.sufficientColorVariance, rg: Math.abs(var_r - var_g) / Math.max(var_r, var_g, 1) / this.settings.active.aard.blackframe.sufficientColorVariance,
rb: Math.abs(var_r - var_b) / Math.max(var_r, var_b, 1) / this.settings.activeaard.blackframe.sufficientColorVariance, rb: Math.abs(var_r - var_b) / Math.max(var_r, var_b, 1) / this.settings.active.aard.blackframe.sufficientColorVariance,
gb: Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1) / this.settings.activeaard.blackframe.sufficientColorVariance, gb: Math.abs(var_b - var_g) / Math.max(var_b, var_g, 1) / this.settings.active.aard.blackframe.sufficientColorVariance,
}, },
varianceLimit: this.settings.activeaard.blackframe.sufficientColorVariance, varianceLimit: this.settings.active.aard.blackframe.sufficientColorVariance,
}, },
cumulativeValuePercent: cumulativeValue / (hasSufficientVariance ? this.settings.activeaard.blackframe.cumulativeThresholdLax : this.settings.activeaard.blackframe.cumulativeThresholdStrict), cumulativeValuePercent: cumulativeValue / (hasSufficientVariance ? this.settings.active.aard.blackframe.cumulativeThresholdLax : this.settings.active.aard.blackframe.cumulativeThresholdStrict),
rowMax: rowMax, rowMax: rowMax,
colMax: colMax, colMax: colMax,
}; };
@ -867,7 +867,7 @@ class ArDetector {
// If we detect anything darker than blackLevel, we modify blackLevel to the new lowest value // If we detect anything darker than blackLevel, we modify blackLevel to the new lowest value
const rowOffset = this.canvas.width * (this.canvas.height - 1); const rowOffset = this.canvas.width * (this.canvas.height - 1);
let currentMin = 255, currentMax = 0, colOffset_r, colOffset_g, colOffset_b, colOffset_rb, colOffset_gb, colOffset_bb, blthreshold = this.settings.activeaard.blackbar.threshold; let currentMin = 255, currentMax = 0, colOffset_r, colOffset_g, colOffset_b, colOffset_rb, colOffset_gb, colOffset_bb, blthreshold = this.settings.active.aard.blackbar.threshold;
// detect black level. if currentMax comes above blackbar + blackbar threshold, we know we aren't letterboxed // detect black level. if currentMax comes above blackbar + blackbar threshold, we know we aren't letterboxed

View File

@ -28,8 +28,8 @@ class GuardLine {
} }
setBlackbar(bbconf){ setBlackbar(bbconf){
var bbTop = bbconf.top - this.settings.activeaard.guardLine.edgeTolerancePx; var bbTop = bbconf.top - this.settings.active.aard.guardLine.edgeTolerancePx;
var bbBottom = bbconf.bottom + this.settings.activeaard.guardLine.edgeTolerancePx; var bbBottom = bbconf.bottom + this.settings.active.aard.guardLine.edgeTolerancePx;
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne // to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
// this removes any configs with invalid values or values that dont make sense // this removes any configs with invalid values or values that dont make sense
@ -43,16 +43,16 @@ class GuardLine {
} }
this.imageBar = { this.imageBar = {
top: bbconf.top + 1 + this.settings.activeaard.guardLine.edgeTolerancePx, top: bbconf.top + 1 + this.settings.active.aard.guardLine.edgeTolerancePx,
bottom: bbconf.bottom - 1 - this.settings.activeaard.guardLine.edgeTolerancePx bottom: bbconf.bottom - 1 - this.settings.active.aard.guardLine.edgeTolerancePx
} }
} }
check(image, fallbackMode){ check(image, fallbackMode){
// izračunaj enkrat in shrani na objekt // izračunaj enkrat in shrani na objekt
// calculate once and save object-instance-wide // calculate once and save object-instance-wide
this.blackbarThreshold = this.conf.blackLevel + this.settings.activeaard.blackbar.threshold; this.blackbarThreshold = this.conf.blackLevel + this.settings.active.aard.blackbar.threshold;
this.imageThreshold = this.blackbarThreshold + this.settings.activeaard.blackbar.imageThreshold; this.imageThreshold = this.blackbarThreshold + this.settings.active.aard.blackbar.imageThreshold;
// dejansko testiranje // dejansko testiranje
// actual checks // actual checks
@ -95,7 +95,7 @@ class GuardLine {
return { success: true }; return { success: true };
} }
var offset = parseInt(this.conf.canvas.width * this.settings.activeaard.guardLine.ignoreEdgeMargin) << 2; var offset = parseInt(this.conf.canvas.width * this.settings.active.aard.guardLine.ignoreEdgeMargin) << 2;
var offenders = []; var offenders = [];
var offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index. var offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
@ -160,7 +160,7 @@ class GuardLine {
if(!this.imageBar.top || !this.imageBar.bottom) if(!this.imageBar.top || !this.imageBar.bottom)
return { success: false }; return { success: false };
var offset = (this.conf.canvas.width * this.settings.activeaard.guardLine.ignoreEdgeMargin) << 2; var offset = (this.conf.canvas.width * this.settings.active.aard.guardLine.ignoreEdgeMargin) << 2;
// TODO: implement logo check. // TODO: implement logo check.
@ -169,8 +169,8 @@ class GuardLine {
// check both rows - by the rules and definitions, we shouldn't go out of bounds here. no need to check, then // check both rows - by the rules and definitions, we shouldn't go out of bounds here. no need to check, then
// if(fallbackMode){ // if(fallbackMode){
// var edge_upper = this.settings.activeaard.fallbackMode.noTriggerZonePx; // var edge_upper = this.settings.active.aard.fallbackMode.noTriggerZonePx;
// var edge_lower = this.conf.canvas.height - this.settings.activeaard.fallbackMode.noTriggerZonePx - 1; // var edge_lower = this.conf.canvas.height - this.settings.active.aard.fallbackMode.noTriggerZonePx - 1;
// } // }
// else{ // else{
var edge_upper = this.imageBar.top; var edge_upper = this.imageBar.top;
@ -181,7 +181,7 @@ class GuardLine {
// robu (eden izmed robov je lahko v celoti črn) // robu (eden izmed robov je lahko v celoti črn)
// how many non-black pixels we need to consider this check a success. We only need to detect enough pixels // how many non-black pixels we need to consider this check a success. We only need to detect enough pixels
// on one edge (one of the edges can be black as long as both aren't) // on one edge (one of the edges can be black as long as both aren't)
var successThreshold = (this.conf.canvas.width * this.settings.activeaard.guardLine.imageTestThreshold); var successThreshold = (this.conf.canvas.width * this.settings.active.aard.guardLine.imageTestThreshold);
var rowStart, rowEnd; var rowStart, rowEnd;