From 6400f4cfd69bb70c2509c7c94e437bc1f0b7562c Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 26 May 2020 01:40:42 +0200 Subject: [PATCH] fix shaders ... to an extent --- .../HorizontalAdderGenerator.js | 18 +-- src/options/AutodetectionSettings.vue | 104 +++++++++--------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/ext/lib/ar-detect/gllib/shader-generators/HorizontalAdderGenerator.js b/src/ext/lib/ar-detect/gllib/shader-generators/HorizontalAdderGenerator.js index 2c33c84..9f3c793 100644 --- a/src/ext/lib/ar-detect/gllib/shader-generators/HorizontalAdderGenerator.js +++ b/src/ext/lib/ar-detect/gllib/shader-generators/HorizontalAdderGenerator.js @@ -26,24 +26,24 @@ export function generateHorizontalAdder(sampleRadius, pixelSizeX) { // build adder kernel let adderStatements = 'vec4 rowSum ='; for (let i = sampleRadius - 1; i > 0; i--) { - adderStatements += `${i == sampleRadius - 1 ? '' : '+'} texture2D(u_frame, v_textureCoords + vec2(${-i * pixelSizeX}, 0))`; + adderStatements += `${i == sampleRadius - 1 ? '' : ' +'} texture2D(u_frame, v_textureCoords + vec2(${-i * pixelSizeX}, 0))`; } - adderStatements += `+ texture2D(u_frame, v_textureCoords + vec2(0, 0))`; + adderStatements += ` + texture2D(u_frame, v_textureCoords + vec2(0, 0))`; for (let i = 0; i < sampleRadius; i++) { - adderStatements += `+ texture2D(u_frame, v_textureCoords + vec2(${i * pixelSizeX}, 0))`; + adderStatements += ` + texture2D(u_frame, v_textureCoords + vec2(${i * pixelSizeX}, 0))`; } - adderStatements += ';' + adderStatements += ';'; // build deviance kernel let stdDevStatements = `vec4 diffSum =`; for (let i = sampleRadius - 1; i > 0; i--) { - stdDevStatements = `${i == sampleRadius - 1 ? '' : '+'} abs(texture2D(u_frame, v_textureCoords + vec2(${-i * pixelSizeX}, 0)) - rowAvg)`; + stdDevStatements += `${i == sampleRadius - 1 ? '' : ' +'} abs(texture2D(u_frame, v_textureCoords + vec2(${-i * pixelSizeX}, 0)) - average)`; } - stdDevStatements = `+ abs(texture2D(u_frame, v_textureCoords + vec2(0, 0) - rowAvg)`; + stdDevStatements += `+ abs(texture2D(u_frame, v_textureCoords + vec2(0, 0)) - average)`; for (let i = sampleRadius - 1; i > 0; i--) { - stdDevStatements = `${i == sampleRadius - 1 ? '' : '+'} abs(texture2D(u_frame, v_textureCoords + vec2(${-i * pixelSizeX}, 0)) - rowAvg)`; + stdDevStatements += ` + abs(texture2D(u_frame, v_textureCoords + vec2(${i * pixelSizeX}, 0)) - average)`; } - + stdDevStatements += ';'; const shader = ` precision mediump float; @@ -64,7 +64,7 @@ export function generateHorizontalAdder(sampleRadius, pixelSizeX) { float sumGrayscale = (rowSum.r + rowSum.g + rowSum.b) / 3.0; float diffGrayscale = (diff.r + diff.g + diff.b) / 3.0; - gl_fragColor = vec4(sumGrayscale, diffGrayscale, (average.r + average.g + average.b) / 3.0, 1.0); + gl_FragColor = vec4(sumGrayscale, diffGrayscale, (average.r + average.g + average.b) / 3.0, 1.0); } ` // btw don't forget: output "image" should be way smaller than input frame diff --git a/src/options/AutodetectionSettings.vue b/src/options/AutodetectionSettings.vue index 88ad7d3..0bb4d5c 100644 --- a/src/options/AutodetectionSettings.vue +++ b/src/options/AutodetectionSettings.vue @@ -14,7 +14,7 @@
More often (~60/s)
@@ -98,7 +98,7 @@
@@ -108,7 +108,7 @@
@@ -121,7 +121,7 @@
@@ -147,7 +147,7 @@
Enable fallback mode because I'm super duper sure I'm using firefox right now.
@@ -158,7 +158,7 @@
@@ -168,7 +168,7 @@
@@ -185,7 +185,7 @@
@@ -207,7 +207,7 @@
@@ -217,7 +217,7 @@
@@ -227,7 +227,7 @@
@@ -237,7 +237,7 @@
@@ -247,7 +247,7 @@
@@ -279,7 +279,7 @@
@@ -289,7 +289,7 @@
@@ -298,7 +298,7 @@ Gradient detection:
- @@ -311,7 +311,7 @@
@@ -321,7 +321,7 @@
@@ -331,7 +331,7 @@
@@ -359,7 +359,7 @@
@@ -369,7 +369,7 @@
@@ -379,7 +379,7 @@
@@ -389,7 +389,7 @@
@@ -399,7 +399,7 @@
@@ -409,7 +409,7 @@
@@ -422,7 +422,7 @@ Sample width — In a bid to detect "false" edges, we take two samples this many pixels wide near the point of our potential edge. One sample must be completely black, the other must contain a set amount of non-black pixels.
Detection threshold — non-black sample mentioned above needs to contain at least this many non-black pixels.
- Thickness quorum (per edge) — amount of samples that agree on the thincknes of the blackbar that we need in order to establish aspect ratio. Every edge needs to have at least this many. Values higher than {{~~(settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold / 2)}} (quorum (total)/2) are pointless.
+ Thickness quorum (per edge) — amount of samples that agree on the thincknes of the blackbar that we need in order to establish aspect ratio. Every edge needs to have at least this many. Values higher than {{~~(settings.active.aard.edgeDetection.singleSideConfirmationThreshold / 2)}} (quorum (total)/2) are pointless.
Thickness quorum (total) — amount of samples that agree on the thinckess of the blackbar that we need in order to establish aspect ratio in case one of the edges doesn't contain enough samples to achieve quorum.
Logo threshold — if edge candidate sits with count greater than this*all_samples, it can't be a logo or a watermark.
Ignore middle area — When trying to detect area, ignore area between middle and canvasHeight * {this value} pixels towards the edge.
@@ -435,7 +435,7 @@
@@ -445,7 +445,7 @@
@@ -455,7 +455,7 @@
@@ -465,7 +465,7 @@
@@ -475,7 +475,7 @@
@@ -485,7 +485,7 @@
@@ -495,7 +495,7 @@
@@ -516,7 +516,7 @@
Enable guardline
@@ -526,7 +526,7 @@
@@ -536,7 +536,7 @@
@@ -546,7 +546,7 @@
@@ -564,7 +564,7 @@
@@ -615,36 +615,36 @@ export default { }, methods: { setArCheckFrequency(event) { - this.settings.active.arDetect.timers.playing = Math.floor(Math.pow(Math.E, event)); + this.settings.active.aard.timers.playing = Math.floor(Math.pow(Math.E, event)); }, getSensitivity() { - if (this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold === 3 && this.settings.active.arDetect.edgeDetection.confirmationThreshold === 1) { + if (this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold === 3 && this.settings.active.aard.edgeDetection.confirmationThreshold === 1) { return 'sensitive'; } - if (this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold === 5 && this.settings.active.arDetect.edgeDetection.confirmationThreshold === 2) { + if (this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold === 5 && this.settings.active.aard.edgeDetection.confirmationThreshold === 2) { return 'balanced'; } - if (this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold === 7 && this.settings.active.arDetect.edgeDetection.confirmationThreshold === 3) { + if (this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold === 7 && this.settings.active.aard.edgeDetection.confirmationThreshold === 3) { return 'accurate'; } - if (this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold === 16 && this.settings.active.arDetect.edgeDetection.confirmationThreshold === 8) { + if (this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold === 16 && this.settings.active.aard.edgeDetection.confirmationThreshold === 8) { return 'strict'; } return 'user-defined'; }, setConfirmationThresholds(sens) { if (sens === 'sensitive') { - this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 3; - this.settings.active.arDetect.edgeDetection.confirmationThreshold = 1; + this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold = 3; + this.settings.active.aard.edgeDetection.confirmationThreshold = 1; } else if (sens === 'balanced') { - this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 5; - this.settings.active.arDetect.edgeDetection.confirmationThreshold = 2; + this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold = 5; + this.settings.active.aard.edgeDetection.confirmationThreshold = 2; } else if (sens === 'accurate') { - this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 7; - this.settings.active.arDetect.edgeDetection.confirmationThreshold = 3; + this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold = 7; + this.settings.active.aard.edgeDetection.confirmationThreshold = 3; } else if (sens === 'strict') { - this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold = 16; - this.settings.active.arDetect.edgeDetection.confirmationThreshold = 8; + this.settings.active.aard.edgeDetection.singleSideConfirmationThreshold = 16; + this.settings.active.aard.edgeDetection.confirmationThreshold = 8; } this.sensitivity = this.getSensitivity();