Fixed autodetection to the point it at least starts
This commit is contained in:
parent
4082d0afd9
commit
a0900a7dad
@ -5,7 +5,7 @@ const _prod = false;
|
|||||||
var Debug = {
|
var Debug = {
|
||||||
init: true,
|
init: true,
|
||||||
debug: true,
|
debug: true,
|
||||||
keyboard: true,
|
// keyboard: true,
|
||||||
debugResizer: true,
|
debugResizer: true,
|
||||||
debugArDetect: true,
|
debugArDetect: true,
|
||||||
// debugStorage: false,
|
// debugStorage: false,
|
||||||
@ -18,7 +18,7 @@ var Debug = {
|
|||||||
playerDetectDebug: true,
|
playerDetectDebug: true,
|
||||||
periodic: true,
|
periodic: true,
|
||||||
// videoRescan: true,
|
// videoRescan: true,
|
||||||
mousemove: true,
|
// mousemove: true,
|
||||||
arDetect: {
|
arDetect: {
|
||||||
edgeDetect: true
|
edgeDetect: true
|
||||||
},
|
},
|
||||||
|
@ -18,11 +18,8 @@ var ExtensionConf = {
|
|||||||
paused: 3000, // while paused
|
paused: 3000, // while paused
|
||||||
error: 3000, // after error
|
error: 3000, // after error
|
||||||
minimumTimeout: 5,
|
minimumTimeout: 5,
|
||||||
|
tickrate: 100, // 1 tick every this many milliseconds
|
||||||
},
|
},
|
||||||
// timer_playing: 666, // we trigger ar this often (in ms) under this conditions
|
|
||||||
// timer_paused: 3000,
|
|
||||||
// timer_error: 3000,
|
|
||||||
// timer_minimumTimeout: 5, // but regardless of above, we wait this many msec before retriggering
|
|
||||||
autoDisable: { // settings for automatically disabling the extension
|
autoDisable: { // settings for automatically disabling the extension
|
||||||
maxExecutionTime: 6000, // if execution time of main autodetect loop exceeds this many milliseconds,
|
maxExecutionTime: 6000, // if execution time of main autodetect loop exceeds this many milliseconds,
|
||||||
// we disable it.
|
// we disable it.
|
||||||
@ -31,14 +28,27 @@ var ExtensionConf = {
|
|||||||
// FOR FUTURE USE
|
// FOR FUTURE USE
|
||||||
consecutiveArResets: 5 // if aspect ratio reverts immediately after AR change is applied, we disable everything
|
consecutiveArResets: 5 // if aspect ratio reverts immediately after AR change is applied, we disable everything
|
||||||
},
|
},
|
||||||
sampleCanvasSize: { // size of image sample for detecting aspect ratio. Bigger size means more accurate results,
|
canvasDimensions: {
|
||||||
// at the expense of performance
|
blackframeCanvas: { // smaller than sample canvas, blackframe canvas is used to recon for black frames
|
||||||
width: 640,
|
// it's not used to detect aspect ratio by itself, so it can be tiny af
|
||||||
height: 360,
|
width: 16,
|
||||||
|
height: 9,
|
||||||
|
},
|
||||||
|
sampleCanvas: { // size of image sample for detecting aspect ratio. Bigger size means more accurate results,
|
||||||
|
// at the expense of performance
|
||||||
|
width: 640,
|
||||||
|
height: 360,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
hSamples: 640,
|
|
||||||
vSamples: 360,
|
|
||||||
// samplingInterval: 10, // we sample at columns at (width/this) * [ 1 .. this - 1]
|
// samplingInterval: 10, // we sample at columns at (width/this) * [ 1 .. this - 1]
|
||||||
|
blackframe: {
|
||||||
|
cumulativeTreshold: 2560, // if we add values of all pixels together and get more than this, the frame is bright enough.
|
||||||
|
// (note: blackframe is 16x9 px -> 144px total. cumulative treshold can be reached fast)
|
||||||
|
blackPixelsCondition: 0.6, // How much pixels must be black (1 all, 0 none) before we consider frame as black. Takes
|
||||||
|
// precedence over cumulative treshold: if blackPixelsCondition is met, the frame is dark
|
||||||
|
// regardless of whether cumulative treshold has been reached.
|
||||||
|
},
|
||||||
blackbar: {
|
blackbar: {
|
||||||
blackLevel: 10, // everything darker than 10/255 across all RGB components is considered black by
|
blackLevel: 10, // everything darker than 10/255 across all RGB components is considered black by
|
||||||
// default. blackLevel can decrease if we detect darker black.
|
// default. blackLevel can decrease if we detect darker black.
|
||||||
|
@ -36,15 +36,12 @@ class ActionHandler {
|
|||||||
actions = this.settings.active.actions;
|
actions = this.settings.active.actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("----ACTIONS----", actions)
|
|
||||||
|
|
||||||
for (var action of actions) {
|
for (var action of actions) {
|
||||||
console.log("----ACTION:", action);
|
|
||||||
if (!action.scopes) {
|
if (!action.scopes) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var scope in action.scopes) {
|
for (var scope in action.scopes) {
|
||||||
console.log("----ACTION - scope:", action.scopes[scope]);
|
|
||||||
if (! action.scopes[scope].shortcut) {
|
if (! action.scopes[scope].shortcut) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -112,7 +109,7 @@ class ActionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerHandleMouse(videoData) {
|
registerHandleMouse(videoData) {
|
||||||
if (Debug.debug) {
|
if (Debug.debug && Debug.mousemove) {
|
||||||
console.log("[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData)
|
console.log("[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData)
|
||||||
}
|
}
|
||||||
var ths = this;
|
var ths = this;
|
||||||
|
@ -231,7 +231,7 @@ class Settings {
|
|||||||
try {
|
try {
|
||||||
// if site-specific settings don't exist for the site, we use default mode:
|
// if site-specific settings don't exist for the site, we use default mode:
|
||||||
if (! this.active.sites[site]) {
|
if (! this.active.sites[site]) {
|
||||||
if (this.active.sites['@global'] === ExtensionMode.Enable) {
|
if (this.active.sites['@global'] === ExtensionMode.Enabled) {
|
||||||
return ExtensionMode.Enabled;
|
return ExtensionMode.Enabled;
|
||||||
} else {
|
} else {
|
||||||
return this.active.basicExtensionMode === ExtensionMode.Enable ? ExtensionMode.Basic : ExtensionMode.Disabled;
|
return this.active.basicExtensionMode === ExtensionMode.Enable ? ExtensionMode.Basic : ExtensionMode.Disabled;
|
||||||
@ -243,7 +243,7 @@ class Settings {
|
|||||||
} else if (this.active.sites[site].mode === ExtensionMode.Basic) {
|
} else if (this.active.sites[site].mode === ExtensionMode.Basic) {
|
||||||
return ExtensionMode.Basic;
|
return ExtensionMode.Basic;
|
||||||
} else if (this.active.sites[site].mode === ExtensionMode.Default) {
|
} else if (this.active.sites[site].mode === ExtensionMode.Default) {
|
||||||
if (this.active.sites['@global'] === ExtensionMode.Enable) {
|
if (this.active.sites['@global'] === ExtensionMode.Enabled) {
|
||||||
return ExtensionMode.Enabled;
|
return ExtensionMode.Enabled;
|
||||||
} else {
|
} else {
|
||||||
return this.active.basicExtensionMode === ExtensionMode.Enable ? ExtensionMode.Basic : ExtensionMode.Disabled;
|
return this.active.basicExtensionMode === ExtensionMode.Enable ? ExtensionMode.Basic : ExtensionMode.Disabled;
|
||||||
@ -283,10 +283,10 @@ class Settings {
|
|||||||
try{
|
try{
|
||||||
// if site is not defined, we use default mode:
|
// if site is not defined, we use default mode:
|
||||||
if (! this.active.sites[site]) {
|
if (! this.active.sites[site]) {
|
||||||
return this.active.sites['@global'] === ExtensionMode.Enable;
|
return this.active.sites['@global'] === ExtensionMode.Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.active.sites['@global'] === ExtensionMode.Enable) {
|
if(this.active.sites['@global'] === ExtensionMode.Enabled) {
|
||||||
return this.active.sites[site].mode !== ExtensionMode.Disabled;
|
return this.active.sites[site].mode !== ExtensionMode.Disabled;
|
||||||
} else if (this.active.sites['@global'] === ExtensionMode.Whitelist) {
|
} else if (this.active.sites['@global'] === ExtensionMode.Whitelist) {
|
||||||
return this.active.sites[site].mode === ExtensionMode.Enabled;
|
return this.active.sites[site].mode === ExtensionMode.Enabled;
|
||||||
@ -310,10 +310,12 @@ class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canStartAutoAr(site) {
|
canStartAutoAr(site) {
|
||||||
|
console.log("SITE:", site)
|
||||||
if (!site) {
|
if (!site) {
|
||||||
site = window.location.hostname;
|
site = window.location.host;
|
||||||
|
|
||||||
if (!site) {
|
if (!site) {
|
||||||
|
console.log("site should be window.location.host")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,23 +328,26 @@ class Settings {
|
|||||||
const csar = this.canStartAutoAr(site);
|
const csar = this.canStartAutoAr(site);
|
||||||
Debug.debug = true;
|
Debug.debug = true;
|
||||||
|
|
||||||
console.log("[Settings::canStartAutoAr] ----------------\nCAN WE START THIS EXTENSION ON SITE", site,
|
console.log("[Settings::canStartAutoAr] ----------------\nCAN WE START AUTOAR ON SITE", site,
|
||||||
"?\n\nsettings.active.sites[site]=", this.active.sites[site],
|
"?\n\nsettings.active.sites[site]=", this.active.sites[site], "settings.active.sites[@global]=", this.active.sites['@global'],
|
||||||
"\nExtension mode?", this.active.sites['@global'].autoar,
|
"\nAutoar mode (global)?", this.active.sites['@global'].autoar,
|
||||||
"\nCan extension be started?", csar
|
`\nAutoar mode (${site})`, this.active.sites[site] ? this.active.sites[site].autoar : '<not defined>',
|
||||||
|
"\nCan autoar be started?", csar
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if site is not defined, we use default mode:
|
// if site is not defined, we use default mode:
|
||||||
if (! this.active.sites[site]) {
|
if (! this.active.sites[site]) {
|
||||||
return this.active.sites['@global'].autoar === ExtensionMode.Enable;
|
return this.active.sites['@global'].autoar === ExtensionMode.Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.active.sites['@global'].autoar === ExtensionMode.Enable) {
|
if (this.active.sites['@global'].autoar === ExtensionMode.Enabled) {
|
||||||
return this.active.sites[site].autoar !== ExtensionMode.Disabled;
|
return this.active.sites[site].autoar !== ExtensionMode.Disabled;
|
||||||
} else if (this.active.sites['@global'].autoar === ExtensionMode.Whitelist) {
|
} else if (this.active.sites['@global'].autoar === ExtensionMode.Whitelist) {
|
||||||
return this.active.sites[site].autoar === ExtensionMode.Enable;
|
console.log("canStartAutoAr — can(not) start csar because extension is in whitelist mode, and this site is (not) equal to", ExtensionMode.Enabled)
|
||||||
|
return this.active.sites[site].autoar === ExtensionMode.Enabled;
|
||||||
} else {
|
} else {
|
||||||
|
console.log("canStartAutoAr — cannot start csar because extension is globally disabled")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -53,7 +53,8 @@ class GuardLine {
|
|||||||
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.blackbarTreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbarTreshold;
|
this.blackbarTreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.treshold;
|
||||||
|
this.imageTreshold = this.blackbarTreshold + this.settings.active.arDetect.blackbar.imageTreshold;
|
||||||
|
|
||||||
// dejansko testiranje
|
// dejansko testiranje
|
||||||
// actual checks
|
// actual checks
|
||||||
@ -100,7 +101,6 @@ class GuardLine {
|
|||||||
var offset = parseInt(this.conf.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
var offset = parseInt(this.conf.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
||||||
|
|
||||||
var offenders = [];
|
var offenders = [];
|
||||||
var firstOffender = -1;
|
|
||||||
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.
|
||||||
|
|
||||||
// TODO: implement logo check.
|
// TODO: implement logo check.
|
||||||
@ -163,7 +163,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 = parseInt(this.conf.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
var offset = (this.conf.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
||||||
|
|
||||||
// TODO: implement logo check.
|
// TODO: implement logo check.
|
||||||
|
|
||||||
@ -184,7 +184,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 successTreshold = parseInt(this.conf.canvas.width * this.settings.active.arDetect.guardLine.imageTestTreshold);
|
var successTreshold = (this.conf.canvas.width * this.settings.active.arDetect.guardLine.imageTestTreshold);
|
||||||
var rowStart, rowEnd;
|
var rowStart, rowEnd;
|
||||||
|
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class GuardLine {
|
|||||||
|
|
||||||
_ti_checkRow(image, rowStart, rowEnd, successTreshold) {
|
_ti_checkRow(image, rowStart, rowEnd, successTreshold) {
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(var i = rowStart; i < rowEnd; i+=4){
|
||||||
if(image[i] > this.blackbarTreshold || image[i+1] > this.blackbarTreshold || image[i+2] > this.blackbarTreshold){
|
if(image[i] > this.imageTreshold || image[i+1] > this.imageTreshold || image[i+2] > this.imageTreshold){
|
||||||
if(successTreshold --<= 0){
|
if(successTreshold --<= 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ class GuardLine {
|
|||||||
|
|
||||||
_ti_debugCheckRow(image, rowStart, rowEnd, successTreshold) {
|
_ti_debugCheckRow(image, rowStart, rowEnd, successTreshold) {
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(var i = rowStart; i < rowEnd; i+=4){
|
||||||
if(image[i] > this.blackbarTreshold || image[i+1] > this.blackbarTreshold || image[i+2] > this.blackbarTreshold){
|
if(image[i] > this.imageTreshold || image[i+1] > this.imageTreshold || image[i+2] > this.imageTreshold){
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
||||||
if(successTreshold --<= 0){
|
if(successTreshold --<= 0){
|
||||||
return true;
|
return true;
|
||||||
|
@ -22,7 +22,7 @@ class EdgeDetect{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findBars(image, sampleCols, direction = EdgeDetectPrimaryDirection.VERTICAL, quality = EdgeDetectQuality.IMPROVED, guardLineOut){
|
findBars(image, sampleCols, direction = EdgeDetectPrimaryDirection.VERTICAL, quality = EdgeDetectQuality.IMPROVED, guardLineOut, blackLevelAnalysis){
|
||||||
var fastCandidates, edgeCandidates, bars;
|
var fastCandidates, edgeCandidates, bars;
|
||||||
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
||||||
fastCandidates = this.findCandidates(image, sampleCols, guardLineOut);
|
fastCandidates = this.findCandidates(image, sampleCols, guardLineOut);
|
||||||
|
@ -78,10 +78,7 @@
|
|||||||
<small>NOTE: in case you're using nightly builds, this extension could be completely broken.
|
<small>NOTE: in case you're using nightly builds, this extension could be completely broken.
|
||||||
It's also possible that everything is getting logged excessively, which may result in
|
It's also possible that everything is getting logged excessively, which may result in
|
||||||
degraded performance. If settings don't persist, check whether Debug.flushStorageSettings is set to true.</small>
|
degraded performance. If settings don't persist, check whether Debug.flushStorageSettings is set to true.</small>
|
||||||
<ShortcutButton class="button"
|
|
||||||
@click.native="settings.setDefaultSettings()"
|
|
||||||
label="Wipe settings"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VideoPanel v-if="settings && settings.active && selectedTab === 'video'"
|
<VideoPanel v-if="settings && settings.active && selectedTab === 'video'"
|
||||||
class=""
|
class=""
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w100 flex flex-column">
|
<div class="w100 flex flex-column">
|
||||||
|
<ShortcutButton class="button"
|
||||||
|
@click.native="settings.setDefaultSettings()"
|
||||||
|
label="Wipe settings"
|
||||||
|
/>
|
||||||
<div v-if="settings && true"
|
<div v-if="settings && true"
|
||||||
class="w100"
|
class="w100"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user