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 = {
|
||||
init: true,
|
||||
debug: true,
|
||||
keyboard: true,
|
||||
// keyboard: true,
|
||||
debugResizer: true,
|
||||
debugArDetect: true,
|
||||
// debugStorage: false,
|
||||
@ -18,7 +18,7 @@ var Debug = {
|
||||
playerDetectDebug: true,
|
||||
periodic: true,
|
||||
// videoRescan: true,
|
||||
mousemove: true,
|
||||
// mousemove: true,
|
||||
arDetect: {
|
||||
edgeDetect: true
|
||||
},
|
||||
|
@ -18,11 +18,8 @@ var ExtensionConf = {
|
||||
paused: 3000, // while paused
|
||||
error: 3000, // after error
|
||||
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
|
||||
maxExecutionTime: 6000, // if execution time of main autodetect loop exceeds this many milliseconds,
|
||||
// we disable it.
|
||||
@ -31,14 +28,27 @@ var ExtensionConf = {
|
||||
// FOR FUTURE USE
|
||||
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,
|
||||
// at the expense of performance
|
||||
width: 640,
|
||||
height: 360,
|
||||
canvasDimensions: {
|
||||
blackframeCanvas: { // smaller than sample canvas, blackframe canvas is used to recon for black frames
|
||||
// it's not used to detect aspect ratio by itself, so it can be tiny af
|
||||
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]
|
||||
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: {
|
||||
blackLevel: 10, // everything darker than 10/255 across all RGB components is considered black by
|
||||
// default. blackLevel can decrease if we detect darker black.
|
||||
|
@ -36,15 +36,12 @@ class ActionHandler {
|
||||
actions = this.settings.active.actions;
|
||||
}
|
||||
|
||||
console.log("----ACTIONS----", actions)
|
||||
|
||||
for (var action of actions) {
|
||||
console.log("----ACTION:", action);
|
||||
if (!action.scopes) {
|
||||
continue;
|
||||
}
|
||||
for (var scope in action.scopes) {
|
||||
console.log("----ACTION - scope:", action.scopes[scope]);
|
||||
if (! action.scopes[scope].shortcut) {
|
||||
continue;
|
||||
}
|
||||
@ -112,7 +109,7 @@ class ActionHandler {
|
||||
}
|
||||
|
||||
registerHandleMouse(videoData) {
|
||||
if (Debug.debug) {
|
||||
if (Debug.debug && Debug.mousemove) {
|
||||
console.log("[ActionHandler::registerHandleMouse] registering handle mouse for videodata:", videoData)
|
||||
}
|
||||
var ths = this;
|
||||
|
@ -231,7 +231,7 @@ class Settings {
|
||||
try {
|
||||
// if site-specific settings don't exist for the site, we use default mode:
|
||||
if (! this.active.sites[site]) {
|
||||
if (this.active.sites['@global'] === ExtensionMode.Enable) {
|
||||
if (this.active.sites['@global'] === ExtensionMode.Enabled) {
|
||||
return ExtensionMode.Enabled;
|
||||
} else {
|
||||
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) {
|
||||
return ExtensionMode.Basic;
|
||||
} 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;
|
||||
} else {
|
||||
return this.active.basicExtensionMode === ExtensionMode.Enable ? ExtensionMode.Basic : ExtensionMode.Disabled;
|
||||
@ -283,10 +283,10 @@ class Settings {
|
||||
try{
|
||||
// if site is not defined, we use default mode:
|
||||
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;
|
||||
} else if (this.active.sites['@global'] === ExtensionMode.Whitelist) {
|
||||
return this.active.sites[site].mode === ExtensionMode.Enabled;
|
||||
@ -310,10 +310,12 @@ class Settings {
|
||||
}
|
||||
|
||||
canStartAutoAr(site) {
|
||||
console.log("SITE:", site)
|
||||
if (!site) {
|
||||
site = window.location.hostname;
|
||||
site = window.location.host;
|
||||
|
||||
if (!site) {
|
||||
console.log("site should be window.location.host")
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -326,23 +328,26 @@ class Settings {
|
||||
const csar = this.canStartAutoAr(site);
|
||||
Debug.debug = true;
|
||||
|
||||
console.log("[Settings::canStartAutoAr] ----------------\nCAN WE START THIS EXTENSION ON SITE", site,
|
||||
"?\n\nsettings.active.sites[site]=", this.active.sites[site],
|
||||
"\nExtension mode?", this.active.sites['@global'].autoar,
|
||||
"\nCan extension be started?", csar
|
||||
console.log("[Settings::canStartAutoAr] ----------------\nCAN WE START AUTOAR ON SITE", site,
|
||||
"?\n\nsettings.active.sites[site]=", this.active.sites[site], "settings.active.sites[@global]=", this.active.sites['@global'],
|
||||
"\nAutoar mode (global)?", this.active.sites['@global'].autoar,
|
||||
`\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 (! 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;
|
||||
} 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 {
|
||||
console.log("canStartAutoAr — cannot start csar because extension is globally disabled")
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,7 +53,8 @@ class GuardLine {
|
||||
check(image, fallbackMode){
|
||||
// izračunaj enkrat in shrani na objekt
|
||||
// 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
|
||||
// actual checks
|
||||
@ -100,7 +101,6 @@ class GuardLine {
|
||||
var offset = parseInt(this.conf.canvas.width * this.settings.active.arDetect.guardLine.ignoreEdgeMargin) << 2;
|
||||
|
||||
var offenders = [];
|
||||
var firstOffender = -1;
|
||||
var offenderCount = -1; // doing it this way means first offender has offenderCount==0. Ez index.
|
||||
|
||||
// TODO: implement logo check.
|
||||
@ -163,7 +163,7 @@ class GuardLine {
|
||||
if(!this.imageBar.top || !this.imageBar.bottom)
|
||||
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.
|
||||
|
||||
@ -184,7 +184,7 @@ class GuardLine {
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ class GuardLine {
|
||||
|
||||
_ti_checkRow(image, rowStart, rowEnd, successTreshold) {
|
||||
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){
|
||||
return true;
|
||||
}
|
||||
@ -291,7 +291,7 @@ class GuardLine {
|
||||
|
||||
_ti_debugCheckRow(image, rowStart, rowEnd, successTreshold) {
|
||||
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);
|
||||
if(successTreshold --<= 0){
|
||||
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;
|
||||
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
||||
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.
|
||||
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>
|
||||
<ShortcutButton class="button"
|
||||
@click.native="settings.setDefaultSettings()"
|
||||
label="Wipe settings"
|
||||
/>
|
||||
|
||||
|
||||
<VideoPanel v-if="settings && settings.active && selectedTab === 'video'"
|
||||
class=""
|
||||
|
@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<div class="w100 flex flex-column">
|
||||
<ShortcutButton class="button"
|
||||
@click.native="settings.setDefaultSettings()"
|
||||
label="Wipe settings"
|
||||
/>
|
||||
<div v-if="settings && true"
|
||||
class="w100"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user