Gradient detect mode
This commit is contained in:
parent
978bd41386
commit
aa4dbc15f6
7
src/common/enums/anti-gradient-mode.enum.js
Normal file
7
src/common/enums/anti-gradient-mode.enum.js
Normal file
@ -0,0 +1,7 @@
|
||||
var AntiGradientMode = Object.freeze({
|
||||
Disabled: 0,
|
||||
Lax: 1,
|
||||
Strict: 2
|
||||
});
|
||||
|
||||
export default EdgeDetectPrimaryDirection;
|
@ -9,7 +9,7 @@ var Debug = {
|
||||
// debug: false,
|
||||
// keyboard: true,
|
||||
// debugResizer: true,
|
||||
debugArDetect: true,
|
||||
// debugArDetect: true,
|
||||
// debugStorage: false,
|
||||
// debugStorage: true,
|
||||
// comms: false,
|
||||
@ -18,7 +18,7 @@ var Debug = {
|
||||
// flushStoredSettings: true,
|
||||
flushStoredSettings: false,
|
||||
// playerDetectDebug: true,
|
||||
periodic: true,
|
||||
// periodic: true,
|
||||
// videoRescan: true,
|
||||
// mousemove: true,
|
||||
arDetect: {
|
||||
|
@ -3,6 +3,7 @@ import currentBrowser from './BrowserDetect';
|
||||
import VideoAlignment from '../../common/enums/video-alignment.enum';
|
||||
import Stretch from '../../common/enums/stretch.enum';
|
||||
import ExtensionMode from '../../common/enums/extension-mode.enum';
|
||||
import AntiGradientMode from '../../common/enums/anti-gradient-mode.enum';
|
||||
|
||||
if(Debug.debug)
|
||||
console.log("Loading: ExtensionConf.js");
|
||||
@ -61,6 +62,8 @@ var ExtensionConf = {
|
||||
// the last pixel that's darker than our treshold, and position of the first pixel that's
|
||||
// brighter than our image treshold. If positions are more than this many pixels apart,
|
||||
// we assume we aren't looking at letterbox and thus don't correct the aspect ratio.
|
||||
gradientSampleSize: 8, // How far do we look to find the gradient
|
||||
antiGradientMode: AntiGradientMode.Strict,
|
||||
},
|
||||
variableBlackbarTresholdOptions: { // In case of poor bitrate videos, jpeg artifacts may cause us issues
|
||||
// FOR FUTURE USE
|
||||
|
@ -140,19 +140,29 @@ class EdgeDetect{
|
||||
const res_bottom = [];
|
||||
|
||||
for (let item of res_top_preliminary) {
|
||||
if (!item.image) {
|
||||
continue;
|
||||
}
|
||||
if (item.image > -1 && item.image <= item.black + this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
||||
res_top.push({top: item.image, col: item.col});
|
||||
} else if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax) {
|
||||
if (item.image === undefined || item.image <= item.black + this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
res_top.push({top: item.image, col: item.col});
|
||||
}
|
||||
} else {
|
||||
if ( item.image !== undefined && item.image <= item.black + this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
res_top.push({top: item.image, col: item.col});
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let item of res_bottom_preliminary) {
|
||||
if (!item.image) {
|
||||
continue;
|
||||
}
|
||||
if (item.image >= item.black - this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
||||
res_bottom.push({bottom: item.image, col: item.col});
|
||||
} else {
|
||||
if ( (item.image !== undefined || this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax)
|
||||
&& item.image >= item.black - this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
res_bottom.push({bottom: item.image, col: item.col});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,7 +561,6 @@ class EdgeDetect{
|
||||
colsOut[c].black = (i / this.conf.canvasImageDataRowLength) - 1;
|
||||
colsOut[c].col = colsIn[c].value;
|
||||
colsIn[c].blackFound = 1;
|
||||
console.log("BLACK FOUND AT COL:", colsIn[c].value, '|', colsOut[c].col, "LINE:", colsOut[c].black, colsOut, colsOut[c])
|
||||
|
||||
// prisili, da se zanka izvede še enkrat ter preveri,
|
||||
// ali trenuten piksel preseže tudi imageTreshold
|
||||
@ -562,7 +571,7 @@ class EdgeDetect{
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (colsIn[c].blackFound++ > this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
if (colsIn[c].blackFound++ > this.settings.active.arDetect.blackbar.gradientSampleSize) {
|
||||
colsIn[c].imageFound = true;
|
||||
continue;
|
||||
}
|
||||
@ -605,7 +614,6 @@ class EdgeDetect{
|
||||
colsOut[c].black = (i / this.conf.canvasImageDataRowLength);
|
||||
colsOut[c].col = colsIn[c].value;
|
||||
colsIn[c].blackFound = true;
|
||||
console.log("BLACK FOUND AT COL:", colsIn[c].value, '|', colsOut[c].col, "LINE:", colsOut[c].black, colsOut, colsOut[c])
|
||||
|
||||
// prisili, da se zanka izvede še enkrat ter preveri,
|
||||
// ali trenuten piksel preseže tudi imageTreshold
|
||||
@ -616,7 +624,7 @@ class EdgeDetect{
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (colsIn[c].blackFound++ > this.settings.active.arDetect.blackbar.gradientTreshold) {
|
||||
if (colsIn[c].blackFound++ > this.settings.active.arDetect.blackbar.gradientSampleSize) {
|
||||
colsIn[c].imageFound = true;
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user