Typo fixes
This commit is contained in:
parent
fbd7aad9b9
commit
d4cd1fd92e
@ -44,33 +44,33 @@ var ExtensionConf = {
|
|||||||
|
|
||||||
// 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: {
|
blackframe: {
|
||||||
cumulativeTreshold: 2560, // if we add values of all pixels together and get more than this, the frame is bright enough.
|
cumulativeThreshold: 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)
|
// (note: blackframe is 16x9 px -> 144px total. cumulative threshold can be reached fast)
|
||||||
blackPixelsCondition: 0.6, // How much pixels must be black (1 all, 0 none) before we consider frame as black. Takes
|
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
|
// precedence over cumulative threshold: if blackPixelsCondition is met, the frame is dark
|
||||||
// regardless of whether cumulative treshold has been reached.
|
// regardless of whether cumulative threshold 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.
|
||||||
treshold: 16, // if pixel is darker than the sum of black level and this value, we count it as black
|
threshold: 16, // if pixel is darker than the sum of black level and this value, we count it as black
|
||||||
// on 0-255. Needs to be fairly high (8 might not cut it) due to compression
|
// on 0-255. Needs to be fairly high (8 might not cut it) due to compression
|
||||||
// artifacts in the video itself
|
// artifacts in the video itself
|
||||||
imageTreshold: 4, // in order to detect pixel as "not black", the pixel must be brighter than
|
imageThreshold: 4, // in order to detect pixel as "not black", the pixel must be brighter than
|
||||||
// the sum of black level, treshold and this value.
|
// the sum of black level, threshold and this value.
|
||||||
gradientTreshold: 2, // When trying to determine thickness of the black bars, we take 2 values: position of
|
gradientThreshold: 2, // When trying to determine thickness of the black bars, we take 2 values: position of
|
||||||
// the last pixel that's darker than our treshold, and position of the first pixel that's
|
// the last pixel that's darker than our threshold, and position of the first pixel that's
|
||||||
// brighter than our image treshold. If positions are more than this many pixels apart,
|
// brighter than our image threshold. 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.
|
// 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
|
gradientSampleSize: 8, // How far do we look to find the gradient
|
||||||
antiGradientMode: AntiGradientMode.Strict,
|
antiGradientMode: AntiGradientMode.Strict,
|
||||||
},
|
},
|
||||||
variableBlackbarTresholdOptions: { // In case of poor bitrate videos, jpeg artifacts may cause us issues
|
variableBlackbarThresholdOptions: { // In case of poor bitrate videos, jpeg artifacts may cause us issues
|
||||||
// FOR FUTURE USE
|
// FOR FUTURE USE
|
||||||
enabled: true, // allow increasing blackbar threshold
|
enabled: true, // allow increasing blackbar threshold
|
||||||
disableArDetectOnMax: true, // disable autodetection when treshold goes over max blackbar treshold
|
disableArDetectOnMax: true, // disable autodetection when threshold goes over max blackbar threshold
|
||||||
maxBlackbarTreshold: 48, // max threshold (don't increase past this)
|
maxBlackbarThreshold: 48, // max threshold (don't increase past this)
|
||||||
thresholdStep: 8, // when failing to set aspect ratio, increase treshold by this much
|
thresholdStep: 8, // when failing to set aspect ratio, increase threshold by this much
|
||||||
increaseAfterConsecutiveResets: 2 // increase if AR resets this many times in a row
|
increaseAfterConsecutiveResets: 2 // increase if AR resets this many times in a row
|
||||||
},
|
},
|
||||||
sampling: {
|
sampling: {
|
||||||
@ -83,7 +83,7 @@ var ExtensionConf = {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
ignoreEdgeMargin: 0.20, // we ignore anything that pokes over the black line this close to the edge
|
ignoreEdgeMargin: 0.20, // we ignore anything that pokes over the black line this close to the edge
|
||||||
// (relative to width of the sample)
|
// (relative to width of the sample)
|
||||||
imageTestTreshold: 0.1, // when testing for image, this much pixels must be over blackbarTreshold
|
imageTestThreshold: 0.1, // when testing for image, this much pixels must be over blackbarThreshold
|
||||||
edgeTolerancePx: 2, // black edge violation is performed this far from reported 'last black pixel'
|
edgeTolerancePx: 2, // black edge violation is performed this far from reported 'last black pixel'
|
||||||
edgeTolerancePercent: null // unused. same as above, except use % of canvas height instead of pixels
|
edgeTolerancePercent: null // unused. same as above, except use % of canvas height instead of pixels
|
||||||
},
|
},
|
||||||
@ -98,12 +98,12 @@ var ExtensionConf = {
|
|||||||
},
|
},
|
||||||
edgeDetection: {
|
edgeDetection: {
|
||||||
sampleWidth: 8, // we take a sample this wide for edge detection
|
sampleWidth: 8, // we take a sample this wide for edge detection
|
||||||
detectionTreshold: 4, // sample needs to have this many non-black pixels to be a valid edge
|
detectionThreshold: 4, // sample needs to have this many non-black pixels to be a valid edge
|
||||||
confirmationTreshold: 0, //
|
confirmationThreshold: 0, //
|
||||||
singleSideConfirmationTreshold: 0.3, // we need this much edges (out of all samples, not just edges) in order
|
singleSideConfirmationThreshold: 0.3, // we need this much edges (out of all samples, not just edges) in order
|
||||||
// to confirm an edge in case there's no edges on top or bottom (other
|
// to confirm an edge in case there's no edges on top or bottom (other
|
||||||
// than logo, of course)
|
// than logo, of course)
|
||||||
logoTreshold: 0.15, // if edge candidate sits with count greater than this*all_samples, it can't be logo
|
logoThreshold: 0.15, // if edge candidate sits with count greater than this*all_samples, it can't be logo
|
||||||
// or watermark.
|
// or watermark.
|
||||||
edgeTolerancePx: 1, // we check for black edge violation this far from detection point
|
edgeTolerancePx: 1, // we check for black edge violation this far from detection point
|
||||||
edgeTolerancePercent: null, // we check for black edge detection this % of height from detection point. unused
|
edgeTolerancePercent: null, // we check for black edge detection this % of height from detection point. unused
|
||||||
@ -119,8 +119,8 @@ var ExtensionConf = {
|
|||||||
textLineTest: {
|
textLineTest: {
|
||||||
nonTextPulse: 0.10, // if a single continuous pulse has this many non-black pixels, we aren't dealing
|
nonTextPulse: 0.10, // if a single continuous pulse has this many non-black pixels, we aren't dealing
|
||||||
// with text. This value is relative to canvas width (%)
|
// with text. This value is relative to canvas width (%)
|
||||||
pulsesToConfirm: 10, // this is a treshold to confirm we're seeing text.
|
pulsesToConfirm: 10, // this is a threshold to confirm we're seeing text.
|
||||||
pulsesToConfirmIfHalfBlack: 5, // this is the treshold to confirm we're seeing text if longest black pulse
|
pulsesToConfirmIfHalfBlack: 5, // this is the threshold to confirm we're seeing text if longest black pulse
|
||||||
// is over 50% of the canvas width
|
// is over 50% of the canvas width
|
||||||
testRowOffset: 0.02 // we test this % of height from detected edge
|
testRowOffset: 0.02 // we test this % of height from detected edge
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ class ArDetector {
|
|||||||
if(Debug.debug && Debug.debugArDetect){
|
if(Debug.debug && Debug.debugArDetect){
|
||||||
console.log(`%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost);
|
console.log(`%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost);
|
||||||
}
|
}
|
||||||
// console.log("SAMPLES:", blackbarSamples, "candidates:", edgeCandidates, "post:", edgePost,"\n\nblack level:", this.blackLevel, "tresh:", this.blackLevel + this.settings.active.arDetect.blackbar.treshold);
|
// console.log("SAMPLES:", blackbarSamples, "candidates:", edgeCandidates, "post:", edgePost,"\n\nblack level:", this.blackLevel, "tresh:", this.blackLevel + this.settings.active.arDetect.blackbar.threshold);
|
||||||
|
|
||||||
if (edgePost.status !== EdgeStatus.AR_KNOWN){
|
if (edgePost.status !== EdgeStatus.AR_KNOWN){
|
||||||
// rob ni bil zaznan, zato ne naredimo ničesar.
|
// rob ni bil zaznan, zato ne naredimo ničesar.
|
||||||
@ -798,7 +798,7 @@ class ArDetector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isBlack: (blackPixelCount/(cols * rows) > this.settings.active.arDetect.blackframe.blackPixelsCondition) ? true : cumulativeValue < this.settings.active.arDetect.blackframe.cumulativeTreshold,
|
isBlack: (blackPixelCount/(cols * rows) > this.settings.active.arDetect.blackframe.blackPixelsCondition) ? true : cumulativeValue < this.settings.active.arDetect.blackframe.cumulativeThreshold,
|
||||||
rowMax: rowMax,
|
rowMax: rowMax,
|
||||||
colMax: colMax,
|
colMax: colMax,
|
||||||
};
|
};
|
||||||
@ -811,9 +811,9 @@ 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, bltreshold = this.settings.active.arDetect.blackbar.treshold;
|
let currentMin = 255, currentMax = 0, colOffset_r, colOffset_g, colOffset_b, colOffset_rb, colOffset_gb, colOffset_bb, blthreshold = this.settings.active.arDetect.blackbar.threshold;
|
||||||
|
|
||||||
// detect black level. if currentMax comes above blackbar + blackbar treshold, we know we aren't letterboxed
|
// detect black level. if currentMax comes above blackbar + blackbar threshold, we know we aren't letterboxed
|
||||||
|
|
||||||
for (var i = 0; i < sampleCols.length; ++i){
|
for (var i = 0; i < sampleCols.length; ++i){
|
||||||
colOffset_r = sampleCols[i] << 2;
|
colOffset_r = sampleCols[i] << 2;
|
||||||
@ -829,8 +829,8 @@ class ArDetector {
|
|||||||
currentMax
|
currentMax
|
||||||
);
|
);
|
||||||
|
|
||||||
if (currentMax > this.blackLevel + bltreshold) {
|
if (currentMax > this.blackLevel + blthreshold) {
|
||||||
console.log("CURRENT MAX:", currentMax, "BLACK LEVEL, treshold, bl+t", this.blackLevel, bltreshold, this.blackLevel+bltreshold)
|
console.log("CURRENT MAX:", currentMax, "BLACK LEVEL, threshold, bl+t", this.blackLevel, blthreshold, this.blackLevel+blthreshold)
|
||||||
// we search no further
|
// we search no further
|
||||||
if (currentMin < this.blackLevel) {
|
if (currentMin < this.blackLevel) {
|
||||||
this.blackLevel = currentMin;
|
this.blackLevel = currentMin;
|
||||||
|
@ -53,8 +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.blackbar.treshold;
|
this.blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
||||||
this.imageTreshold = this.blackbarTreshold + this.settings.active.arDetect.blackbar.imageTreshold;
|
this.imageThreshold = this.blackbarThreshold + this.settings.active.arDetect.blackbar.imageThreshold;
|
||||||
|
|
||||||
// dejansko testiranje
|
// dejansko testiranje
|
||||||
// actual checks
|
// actual checks
|
||||||
@ -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 = (this.conf.canvas.width * this.settings.active.arDetect.guardLine.imageTestTreshold);
|
var successThreshold = (this.conf.canvas.width * this.settings.active.arDetect.guardLine.imageTestThreshold);
|
||||||
var rowStart, rowEnd;
|
var rowStart, rowEnd;
|
||||||
|
|
||||||
|
|
||||||
@ -196,9 +196,9 @@ class GuardLine {
|
|||||||
var res = false;
|
var res = false;
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
||||||
res = this._ti_debugCheckRow(image, rowStart, rowEnd, successTreshold);
|
res = this._ti_debugCheckRow(image, rowStart, rowEnd, successThreshold);
|
||||||
} else {
|
} else {
|
||||||
res = this._ti_checkRow(image, rowStart, rowEnd,successTreshold);
|
res = this._ti_checkRow(image, rowStart, rowEnd,successThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res)
|
if(res)
|
||||||
@ -212,9 +212,9 @@ class GuardLine {
|
|||||||
|
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
if(Debug.debugCanvas.enabled && Debug.debugCanvas.guardLine){
|
||||||
res = this._ti_debugCheckRow(image, rowStart, rowEnd, successTreshold);
|
res = this._ti_debugCheckRow(image, rowStart, rowEnd, successThreshold);
|
||||||
} else {
|
} else {
|
||||||
res = this._ti_checkRow(image, rowStart, rowEnd,successTreshold);
|
res = this._ti_checkRow(image, rowStart, rowEnd,successThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {success: res};
|
return {success: res};
|
||||||
@ -230,7 +230,7 @@ class GuardLine {
|
|||||||
|
|
||||||
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
||||||
// columns to sample
|
// columns to sample
|
||||||
if(image[i] > this.blackbarTreshold || image[i+1] > this.blackbarTreshold || image[i+2] > this.blackbarTreshold){
|
if(image[i] > this.blackbarThreshold || image[i+1] > this.blackbarThreshold || image[i+2] > this.blackbarThreshold){
|
||||||
if(firstOffender < 0){
|
if(firstOffender < 0){
|
||||||
firstOffender = (i - rowStart) >> 2;
|
firstOffender = (i - rowStart) >> 2;
|
||||||
offenderCount++;
|
offenderCount++;
|
||||||
@ -255,7 +255,7 @@ class GuardLine {
|
|||||||
|
|
||||||
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
// we track sections that go over what's supposed to be a black line, so we can suggest more
|
||||||
// columns to sample
|
// columns to sample
|
||||||
if(image[i] > this.blackbarTreshold || image[i+1] > this.blackbarTreshold || image[i+2] > this.blackbarTreshold){
|
if(image[i] > this.blackbarThreshold || image[i+1] > this.blackbarThreshold || image[i+2] > this.blackbarThreshold){
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.VIOLATION);
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.VIOLATION);
|
||||||
if(firstOffender < 0){
|
if(firstOffender < 0){
|
||||||
firstOffender = (i - rowStart) >> 2;
|
firstOffender = (i - rowStart) >> 2;
|
||||||
@ -277,10 +277,10 @@ class GuardLine {
|
|||||||
return offenderCount;
|
return offenderCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ti_checkRow(image, rowStart, rowEnd, successTreshold) {
|
_ti_checkRow(image, rowStart, rowEnd, successThreshold) {
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(var i = rowStart; i < rowEnd; i+=4){
|
||||||
if(image[i] > this.imageTreshold || image[i+1] > this.imageTreshold || image[i+2] > this.imageTreshold){
|
if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
||||||
if(successTreshold --<= 0){
|
if(successThreshold --<= 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,11 +289,11 @@ class GuardLine {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ti_debugCheckRow(image, rowStart, rowEnd, successTreshold) {
|
_ti_debugCheckRow(image, rowStart, rowEnd, successThreshold) {
|
||||||
for(var i = rowStart; i < rowEnd; i+=4){
|
for(var i = rowStart; i < rowEnd; i+=4){
|
||||||
if(image[i] > this.imageTreshold || image[i+1] > this.imageTreshold || image[i+2] > this.imageTreshold){
|
if(image[i] > this.imageThreshold || image[i+1] > this.imageThreshold || image[i+2] > this.imageThreshold){
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.GUARDLINE_IMAGE);
|
||||||
if(successTreshold --<= 0){
|
if(successThreshold --<= 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,7 +16,7 @@ class EdgeDetect{
|
|||||||
this.sampleWidthBase = this.settings.active.arDetect.edgeDetection.sampleWidth << 2; // corrected so we can work on imageData
|
this.sampleWidthBase = this.settings.active.arDetect.edgeDetection.sampleWidth << 2; // corrected so we can work on imageData
|
||||||
this.halfSample = this.sampleWidthBase >> 1;
|
this.halfSample = this.sampleWidthBase >> 1;
|
||||||
|
|
||||||
this.detectionTreshold = this.settings.active.arDetect.edgeDetection.detectionTreshold;
|
this.detectionThreshold = this.settings.active.arDetect.edgeDetection.detectionThreshold;
|
||||||
|
|
||||||
this.init(); // initiate things that can change
|
this.init(); // initiate things that can change
|
||||||
}
|
}
|
||||||
@ -69,12 +69,12 @@ class EdgeDetect{
|
|||||||
console.log("[EdgeDetect::findCandidates] cols a, b:", cols_a, cols_b);
|
console.log("[EdgeDetect::findCandidates] cols a, b:", cols_a, cols_b);
|
||||||
|
|
||||||
|
|
||||||
this.colsTreshold = sampleCols.length * this.settings.active.arDetect.edgeDetection.minColsForSearch;
|
this.colsThreshold = sampleCols.length * this.settings.active.arDetect.edgeDetection.minColsForSearch;
|
||||||
if (this.colsTreshold == 0)
|
if (this.colsThreshold == 0)
|
||||||
this.colsTreshold = 1;
|
this.colsThreshold = 1;
|
||||||
|
|
||||||
this.blackbarTreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.treshold;
|
this.blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
||||||
this.imageTreshold = this.blackbarTreshold + this.settings.active.arDetect.blackbar.imageTreshold;
|
this.imageThreshold = this.blackbarThreshold + this.settings.active.arDetect.blackbar.imageThreshold;
|
||||||
|
|
||||||
// if guardline didn't fail and imageDetect did, we don't have to check the upper few pixels
|
// if guardline didn't fail and imageDetect did, we don't have to check the upper few pixels
|
||||||
// but only if upper and lower edge are defined. If they're not, we need to check full height
|
// but only if upper and lower edge are defined. If they're not, we need to check full height
|
||||||
@ -131,10 +131,10 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// preglejmo, kateri kandidati so neprimerni. (Neprimerni so tisti, pri katerih se
|
// preglejmo, kateri kandidati so neprimerni. (Neprimerni so tisti, pri katerih se
|
||||||
// 'black' in 'image' razlikujeta za več kot settings.arDetect.blackbar.gradientTreshold)
|
// 'black' in 'image' razlikujeta za več kot settings.arDetect.blackbar.gradientThreshold)
|
||||||
//
|
//
|
||||||
// let's check which candidates are suitable. Suitable candidates have 'black' and 'image'
|
// let's check which candidates are suitable. Suitable candidates have 'black' and 'image'
|
||||||
// components differ by less than settings.arDetect.blackbar.gradientTreshold
|
// components differ by less than settings.arDetect.blackbar.gradientThreshold
|
||||||
|
|
||||||
const res_top = [];
|
const res_top = [];
|
||||||
const res_bottom = [];
|
const res_bottom = [];
|
||||||
@ -143,11 +143,11 @@ class EdgeDetect{
|
|||||||
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Disabled) {
|
||||||
res_top.push({top: item.image, col: item.col});
|
res_top.push({top: item.image, col: item.col});
|
||||||
} else if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax) {
|
} else if (this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax) {
|
||||||
if (item.image === undefined || item.image <= item.black + this.settings.active.arDetect.blackbar.gradientTreshold) {
|
if (item.image === undefined || item.image <= item.black + this.settings.active.arDetect.blackbar.gradientThreshold) {
|
||||||
res_top.push({top: item.image, col: item.col});
|
res_top.push({top: item.image, col: item.col});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( item.image !== undefined && item.image <= item.black + this.settings.active.arDetect.blackbar.gradientTreshold) {
|
if ( item.image !== undefined && item.image <= item.black + this.settings.active.arDetect.blackbar.gradientThreshold) {
|
||||||
res_top.push({top: item.image, col: item.col});
|
res_top.push({top: item.image, col: item.col});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ class EdgeDetect{
|
|||||||
res_bottom.push({bottom: item.image, col: item.col});
|
res_bottom.push({bottom: item.image, col: item.col});
|
||||||
} else {
|
} else {
|
||||||
if ( (item.image !== undefined || this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax)
|
if ( (item.image !== undefined || this.settings.active.arDetect.blackbar.antiGradientMode === AntiGradientMode.Lax)
|
||||||
&& item.image >= item.black - this.settings.active.arDetect.blackbar.gradientTreshold) {
|
&& item.image >= item.black - this.settings.active.arDetect.blackbar.gradientThreshold) {
|
||||||
res_bottom.push({bottom: item.image, col: item.col});
|
res_bottom.push({bottom: item.image, col: item.col});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ class EdgeDetect{
|
|||||||
// it could be watermark. It could be a dark frame. Let's check for watermark first.
|
// it could be watermark. It could be a dark frame. Let's check for watermark first.
|
||||||
if( edgesTop[0].distance < edgesBottom[0].distance &&
|
if( edgesTop[0].distance < edgesBottom[0].distance &&
|
||||||
edgesTop[0].count < edgesBottom[0].count &&
|
edgesTop[0].count < edgesBottom[0].count &&
|
||||||
edgesTop[0].count < this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoTreshold){
|
edgesTop[0].count < this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoThreshold){
|
||||||
// možno, da je watermark zgoraj. Preverimo, če se kateri od drugih potencialnih robov na zgornjem robu
|
// možno, da je watermark zgoraj. Preverimo, če se kateri od drugih potencialnih robov na zgornjem robu
|
||||||
// ujema s prvim spodnjim (+/- variance). Če je temu tako, potem bo verjetno watermark. Logo mora imeti
|
// ujema s prvim spodnjim (+/- variance). Če je temu tako, potem bo verjetno watermark. Logo mora imeti
|
||||||
// manj vzorcev kot navaden rob.
|
// manj vzorcev kot navaden rob.
|
||||||
@ -396,7 +396,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
if( edgesBottom[0].distance < edgesTop[0].distance &&
|
if( edgesBottom[0].distance < edgesTop[0].distance &&
|
||||||
edgesBottom[0].count < edgesTop[0].count &&
|
edgesBottom[0].count < edgesTop[0].count &&
|
||||||
edgesBottom[0].count <this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoTreshold){
|
edgesBottom[0].count <this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.logoThreshold){
|
||||||
|
|
||||||
if(edgesBottom[0].length > 1){
|
if(edgesBottom[0].length > 1){
|
||||||
var lowMargin = edgesTop[0].distance - alignMargin;
|
var lowMargin = edgesTop[0].distance - alignMargin;
|
||||||
@ -429,11 +429,11 @@ class EdgeDetect{
|
|||||||
// either the top or the bottom edge remains undetected, but we have one more trick that we
|
// either the top or the bottom edge remains undetected, but we have one more trick that we
|
||||||
// can try. It also tries to work around logos.
|
// can try. It also tries to work around logos.
|
||||||
|
|
||||||
var edgeDetectionTreshold = this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.singleSideConfirmationTreshold;
|
var edgeDetectionThreshold = this.conf.sampleCols.length * this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold;
|
||||||
|
|
||||||
if(edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
|
if(edges.edgeCandidatesTopCount == 0 && edges.edgeCandidatesBottomCount != 0){
|
||||||
for(var edge of edgesBottom){
|
for(var edge of edgesBottom){
|
||||||
if(edge.count >= edgeDetectionTreshold)
|
if(edge.count >= edgeDetectionThreshold)
|
||||||
return {
|
return {
|
||||||
status: EdgeStatus.AR_KNOWN,
|
status: EdgeStatus.AR_KNOWN,
|
||||||
blackbarWidth: edge.distance,
|
blackbarWidth: edge.distance,
|
||||||
@ -447,7 +447,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
if(edges.edgeCandidatesTopCount != 0 && edges.edgeCandidatesBottomCount == 0){
|
if(edges.edgeCandidatesTopCount != 0 && edges.edgeCandidatesBottomCount == 0){
|
||||||
for(var edge of edgesTop){
|
for(var edge of edgesTop){
|
||||||
if(edge.count >= edgeDetectionTreshold)
|
if(edge.count >= edgeDetectionThreshold)
|
||||||
return {
|
return {
|
||||||
status: EdgeStatus.AR_KNOWN,
|
status: EdgeStatus.AR_KNOWN,
|
||||||
blackbarWidth: edge.distance,
|
blackbarWidth: edge.distance,
|
||||||
@ -473,8 +473,8 @@ class EdgeDetect{
|
|||||||
// roughly centered, we return true. Otherwise we return false.
|
// roughly centered, we return true. Otherwise we return false.
|
||||||
// we also return true if we detect too much black
|
// we also return true if we detect too much black
|
||||||
|
|
||||||
var blackbarTreshold, upper, lower;
|
var blackbarThreshold, upper, lower;
|
||||||
blackbarTreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.treshold;
|
blackbarThreshold = this.conf.blackLevel + this.settings.active.arDetect.blackbar.threshold;
|
||||||
|
|
||||||
|
|
||||||
var middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
|
var middleRowStart = (this.conf.canvas.height >> 1) * this.conf.canvas.width;
|
||||||
@ -489,7 +489,7 @@ class EdgeDetect{
|
|||||||
// preverimo na levi strani
|
// preverimo na levi strani
|
||||||
// let's check for edge on the left side
|
// let's check for edge on the left side
|
||||||
for(var i = rowStart; i < midpoint; i+=4){
|
for(var i = rowStart; i < midpoint; i+=4){
|
||||||
if(image[i] > blackbarTreshold || image[i+1] > blackbarTreshold || image[i+2] > blackbarTreshold){
|
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
||||||
edge_left = (i - rowStart) >> 2;
|
edge_left = (i - rowStart) >> 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ class EdgeDetect{
|
|||||||
// preverimo na desni strani
|
// preverimo na desni strani
|
||||||
// check on the right
|
// check on the right
|
||||||
for(var i = rowEnd; i > midpoint; i-= 4){
|
for(var i = rowEnd; i > midpoint; i-= 4){
|
||||||
if(image[i] > blackbarTreshold || image[i+1] > blackbarTreshold || image[i+2] > blackbarTreshold){
|
if(image[i] > blackbarThreshold || image[i+1] > blackbarThreshold || image[i+2] > blackbarThreshold){
|
||||||
edge_right = this.conf.canvas.width - ((i - rowStart) >> 2);
|
edge_right = this.conf.canvas.width - ((i - rowStart) >> 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -552,21 +552,21 @@ class EdgeDetect{
|
|||||||
tmpI = i + (colsIn[c].value << 2);
|
tmpI = i + (colsIn[c].value << 2);
|
||||||
|
|
||||||
// najprej preverimo, če je piksel presegel mejo črnega robu
|
// najprej preverimo, če je piksel presegel mejo črnega robu
|
||||||
// first we check whether blackbarTreshold was exceeded
|
// first we check whether blackbarThreshold was exceeded
|
||||||
if(! colsIn[c].blackFound) {
|
if(! colsIn[c].blackFound) {
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
colsOut[c].black = (i / this.conf.canvasImageDataRowLength) - 1;
|
colsOut[c].black = (i / this.conf.canvasImageDataRowLength) - 1;
|
||||||
colsOut[c].col = colsIn[c].value;
|
colsOut[c].col = colsIn[c].value;
|
||||||
colsIn[c].blackFound = 1;
|
colsIn[c].blackFound = 1;
|
||||||
|
|
||||||
// prisili, da se zanka izvede še enkrat ter preveri,
|
// prisili, da se zanka izvede še enkrat ter preveri,
|
||||||
// ali trenuten piksel preseže tudi imageTreshold
|
// ali trenuten piksel preseže tudi imageThreshold
|
||||||
//
|
//
|
||||||
// force the loop to repeat this step and check whether
|
// force the loop to repeat this step and check whether
|
||||||
// current pixel exceeds imageTreshold as well
|
// current pixel exceeds imageThreshold as well
|
||||||
c--;
|
c--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -577,12 +577,12 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
// zatem preverimo, če je piksel presegel mejo, po kateri sklepamo, da
|
// zatem preverimo, če je piksel presegel mejo, po kateri sklepamo, da
|
||||||
// predstavlja sliko. Preverimo samo, če smo v stolpcu že presegli
|
// predstavlja sliko. Preverimo samo, če smo v stolpcu že presegli
|
||||||
// blackTreshold
|
// blackThreshold
|
||||||
//
|
//
|
||||||
// then we check whether pixel exceeded imageTreshold
|
// then we check whether pixel exceeded imageThreshold
|
||||||
if (image[tmpI] > this.imageTreshold ||
|
if (image[tmpI] > this.imageThreshold ||
|
||||||
image[tmpI + 1] > this.imageTreshold ||
|
image[tmpI + 1] > this.imageThreshold ||
|
||||||
image[tmpI + 2] > this.imageTreshold ){
|
image[tmpI + 2] > this.imageThreshold ){
|
||||||
|
|
||||||
colsOut[c].image = (i / this.conf.canvasImageDataRowLength)
|
colsOut[c].image = (i / this.conf.canvasImageDataRowLength)
|
||||||
colsIn[c].imageFound = true;
|
colsIn[c].imageFound = true;
|
||||||
@ -590,7 +590,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(edgeDetectCount >= this.colsTreshold) {
|
if(edgeDetectCount >= this.colsThreshold) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -605,21 +605,21 @@ class EdgeDetect{
|
|||||||
tmpI = i + (colsIn[c].value << 2);
|
tmpI = i + (colsIn[c].value << 2);
|
||||||
|
|
||||||
// najprej preverimo, če je piksel presegel mejo črnega robu
|
// najprej preverimo, če je piksel presegel mejo črnega robu
|
||||||
// first we check whether blackbarTreshold was exceeded
|
// first we check whether blackbarThreshold was exceeded
|
||||||
if(! colsIn[c].blackFound) {
|
if(! colsIn[c].blackFound) {
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
colsOut[c].black = (i / this.conf.canvasImageDataRowLength);
|
colsOut[c].black = (i / this.conf.canvasImageDataRowLength);
|
||||||
colsOut[c].col = colsIn[c].value;
|
colsOut[c].col = colsIn[c].value;
|
||||||
colsIn[c].blackFound = true;
|
colsIn[c].blackFound = true;
|
||||||
|
|
||||||
// prisili, da se zanka izvede še enkrat ter preveri,
|
// prisili, da se zanka izvede še enkrat ter preveri,
|
||||||
// ali trenuten piksel preseže tudi imageTreshold
|
// ali trenuten piksel preseže tudi imageThreshold
|
||||||
//
|
//
|
||||||
// force the loop to repeat this step and check whether
|
// force the loop to repeat this step and check whether
|
||||||
// current pixel exceeds imageTreshold as well
|
// current pixel exceeds imageThreshold as well
|
||||||
c--;
|
c--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -630,12 +630,12 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
// zatem preverimo, če je piksel presegel mejo, po kateri sklepamo, da
|
// zatem preverimo, če je piksel presegel mejo, po kateri sklepamo, da
|
||||||
// predstavlja sliko. Preverimo samo, če smo v stolpcu že presegli
|
// predstavlja sliko. Preverimo samo, če smo v stolpcu že presegli
|
||||||
// blackTreshold
|
// blackThreshold
|
||||||
//
|
//
|
||||||
// then we check whether pixel exceeded imageTreshold
|
// then we check whether pixel exceeded imageThreshold
|
||||||
if (image[tmpI] > this.imageTreshold ||
|
if (image[tmpI] > this.imageThreshold ||
|
||||||
image[tmpI + 1] > this.imageTreshold ||
|
image[tmpI + 1] > this.imageThreshold ||
|
||||||
image[tmpI + 2] > this.imageTreshold ){
|
image[tmpI + 2] > this.imageThreshold ){
|
||||||
|
|
||||||
colsOut[c].image = (i / this.conf.canvasImageDataRowLength)
|
colsOut[c].image = (i / this.conf.canvasImageDataRowLength)
|
||||||
colsIn[c].imageFound = true;
|
colsIn[c].imageFound = true;
|
||||||
@ -643,7 +643,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(edgeDetectCount >= this.colsTreshold) {
|
if(edgeDetectCount >= this.colsThreshold) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -658,9 +658,9 @@ class EdgeDetect{
|
|||||||
for(var col of colsIn){
|
for(var col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
||||||
colsOut.push({
|
colsOut.push({
|
||||||
@ -670,7 +670,7 @@ class EdgeDetect{
|
|||||||
colsIn.splice(colsIn.indexOf(col), 1);
|
colsIn.splice(colsIn.indexOf(col), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(colsIn.length < this.colsTreshold)
|
if(colsIn.length < this.colsThreshold)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -678,9 +678,9 @@ class EdgeDetect{
|
|||||||
for(var col of colsIn){
|
for(var col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
colsOut.push({
|
colsOut.push({
|
||||||
col: col,
|
col: col,
|
||||||
@ -689,7 +689,7 @@ class EdgeDetect{
|
|||||||
colsIn.splice(colsIn.indexOf(col), 1);
|
colsIn.splice(colsIn.indexOf(col), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(colsIn.length < this.colsTreshold)
|
if(colsIn.length < this.colsThreshold)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,9 +702,9 @@ class EdgeDetect{
|
|||||||
for(var col of colsIn){
|
for(var col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
||||||
colsOut.push({
|
colsOut.push({
|
||||||
@ -718,7 +718,7 @@ class EdgeDetect{
|
|||||||
this.conf.debugCanvas.trace(tmpI, DebugCanvasClasses.EDGEDETECT_ONBLACK);
|
this.conf.debugCanvas.trace(tmpI, DebugCanvasClasses.EDGEDETECT_ONBLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(colsIn.length < this.colsTreshold)
|
if(colsIn.length < this.colsThreshold)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -726,9 +726,9 @@ class EdgeDetect{
|
|||||||
for(var col of colsIn){
|
for(var col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarTreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarTreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarTreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
colsOut.push({
|
colsOut.push({
|
||||||
col: col,
|
col: col,
|
||||||
@ -746,7 +746,7 @@ class EdgeDetect{
|
|||||||
this.conf.debugCanvas.trace(tmpI, DebugCanvasClasses.EDGEDETECT_ONBLACK);
|
this.conf.debugCanvas.trace(tmpI, DebugCanvasClasses.EDGEDETECT_ONBLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(colsIn.length < this.colsTreshold)
|
if(colsIn.length < this.colsThreshold)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -754,9 +754,9 @@ class EdgeDetect{
|
|||||||
|
|
||||||
_blackbarTest(image, start, end){
|
_blackbarTest(image, start, end){
|
||||||
for(var i = start; i < end; i += 4){
|
for(var i = start; i < end; i += 4){
|
||||||
if( image[i ] > this.blackbarTreshold ||
|
if( image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarTreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarTreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -765,9 +765,9 @@ class EdgeDetect{
|
|||||||
|
|
||||||
_blackbarTest_dbg(image, start, end){
|
_blackbarTest_dbg(image, start, end){
|
||||||
for(var i = start; i < end; i += 4){
|
for(var i = start; i < end; i += 4){
|
||||||
if( image[i ] > this.blackbarTreshold ||
|
if( image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarTreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarTreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.VIOLATION)
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.VIOLATION)
|
||||||
return true;
|
return true;
|
||||||
@ -782,13 +782,13 @@ class EdgeDetect{
|
|||||||
var detections = 0;
|
var detections = 0;
|
||||||
|
|
||||||
for(var i = start; i < end; i += 4){
|
for(var i = start; i < end; i += 4){
|
||||||
if( image[i ] > this.blackbarTreshold ||
|
if( image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarTreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarTreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
++detections;
|
++detections;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(detections >= this.detectionTreshold){
|
if(detections >= this.detectionThreshold){
|
||||||
if(edgeCandidates[sampleOffset] != undefined)
|
if(edgeCandidates[sampleOffset] != undefined)
|
||||||
edgeCandidates[sampleOffset].count++;
|
edgeCandidates[sampleOffset].count++;
|
||||||
else{
|
else{
|
||||||
@ -802,16 +802,16 @@ class EdgeDetect{
|
|||||||
var detections = 0;
|
var detections = 0;
|
||||||
|
|
||||||
for(var i = start; i < end; i += 4){
|
for(var i = start; i < end; i += 4){
|
||||||
if( image[i ] > this.blackbarTreshold ||
|
if( image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarTreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarTreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
++detections;
|
++detections;
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.EDGEDETECT_IMAGE);
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.EDGEDETECT_IMAGE);
|
||||||
} else {
|
} else {
|
||||||
this.conf.debugCanvas.trace(i, DebugCanvasClasses.WARN);
|
this.conf.debugCanvas.trace(i, DebugCanvasClasses.WARN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(detections >= this.detectionTreshold){
|
if(detections >= this.detectionThreshold){
|
||||||
if(edgeCandidates[sampleOffset] != undefined)
|
if(edgeCandidates[sampleOffset] != undefined)
|
||||||
edgeCandidates[sampleOffset].count++;
|
edgeCandidates[sampleOffset].count++;
|
||||||
else{
|
else{
|
||||||
|
@ -118,14 +118,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="label">Letterbox misallignment treshold</div>
|
<div class="label">Letterbox misallignment threshold</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
If top and bottom bar differ by more than this (0 — 0%, 1 — 100%), we do not correct aspect ratio.
|
If top and bottom bar differ by more than this (0 — 0%, 1 — 100%), we do not correct aspect ratio.
|
||||||
</div>
|
</div>
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Letterbox misalignment treshold
|
Letterbox misalignment threshold
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type=""
|
<input type=""
|
||||||
@ -203,15 +203,15 @@
|
|||||||
<b>Black level:</b> 0-255, where 0 is black. Anything below this number across all RGB components is considered black.
|
<b>Black level:</b> 0-255, where 0 is black. Anything below this number across all RGB components is considered black.
|
||||||
Black level can decrease if we detect darker blacks in the video. Lower values —> more accurate edge detection;
|
Black level can decrease if we detect darker blacks in the video. Lower values —> more accurate edge detection;
|
||||||
higher values —> detection is more forgiving to videos with less-than-ideal contrast ratios.<br/>
|
higher values —> detection is more forgiving to videos with less-than-ideal contrast ratios.<br/>
|
||||||
<b>Treshold:</b> If pixel is darker than the sum of black level and this value, it's considered black. In theory, lower -> better.
|
<b>Threshold:</b> If pixel is darker than the sum of black level and this value, it's considered black. In theory, lower -> better.
|
||||||
In practice, this value needs to be kept surprisingly high (8 might not be high enough), otherwise compression artifacts in videos
|
In practice, this value needs to be kept surprisingly high (8 might not be high enough), otherwise compression artifacts in videos
|
||||||
start having an adverse effect on quality of automatic detection.
|
start having an adverse effect on quality of automatic detection.
|
||||||
<b>Gradient detection:</b> Attempt to discriminate between hard edges and gradients. 'Strict' and 'Lax' prevent aspect ratio
|
<b>Gradient detection:</b> Attempt to discriminate between hard edges and gradients. 'Strict' and 'Lax' prevent aspect ratio
|
||||||
changes if we detected gradients instead of a legit edge. This results in fewer false positives, but may cause aspect ratio
|
changes if we detected gradients instead of a legit edge. This results in fewer false positives, but may cause aspect ratio
|
||||||
detection to not work on darker frames.<br/>
|
detection to not work on darker frames.<br/>
|
||||||
<b>Image treshold:</b> When gradient detection is enabled, everything that's brighter than the sum of black level, treshold and
|
<b>Image threshold:</b> When gradient detection is enabled, everything that's brighter than the sum of black level, threshold and
|
||||||
ths is considered to be non-black.<br/>
|
ths is considered to be non-black.<br/>
|
||||||
<b>Gradient treshold:</b> If the distance between last black pixel and the first non-black pixel in a given column is more than this value,
|
<b>Gradient threshold:</b> If the distance between last black pixel and the first non-black pixel in a given column is more than this value,
|
||||||
we're looking at a gradient. If this happens while gradient detection is on, we don't change aspect ratio.<br/>
|
we're looking at a gradient. If this happens while gradient detection is on, we don't change aspect ratio.<br/>
|
||||||
<b>Gradient sample size:</b> This option is really only relevant when using 'lax' gradient detection. If we don't find a non-black pixel
|
<b>Gradient sample size:</b> This option is really only relevant when using 'lax' gradient detection. If we don't find a non-black pixel
|
||||||
within this distance after last known black pixel when scanning a column, we presume we're not on a gradient.
|
within this distance after last known black pixel when scanning a column, we presume we're not on a gradient.
|
||||||
@ -229,11 +229,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Treshold:
|
Threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.blackbar.treshold"
|
v-model="settings.active.arDetect.blackbar.threshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -247,21 +247,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="showAdvancedOptions" class="flex flex-row row-padding">
|
<div v-if="showAdvancedOptions" class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Image treshold
|
Image threshold
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.blackbar.imageTreshold"
|
v-model="settings.active.arDetect.blackbar.imageThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showAdvancedOptions" class="flex flex-row row-padding">
|
<div v-if="showAdvancedOptions" class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Gradient treshold:
|
Gradient threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.blackbar.gradientTreshold"
|
v-model="settings.active.arDetect.blackbar.gradientThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -283,8 +283,8 @@
|
|||||||
Black frame detection is a quick test that tries to determine whether we're looking at a black frame. This test prevents
|
Black frame detection is a quick test that tries to determine whether we're looking at a black frame. This test prevents
|
||||||
us from wasting precious time trying to detect aspect ratio on frames that are too dark for reliable aspect ratio detection.<br/>
|
us from wasting precious time trying to detect aspect ratio on frames that are too dark for reliable aspect ratio detection.<br/>
|
||||||
<b>Sample width, height:</b> Sample size. Since we're checking <i>every</i> pixel in this sample, dimensions should be kept small.<br/>
|
<b>Sample width, height:</b> Sample size. Since we're checking <i>every</i> pixel in this sample, dimensions should be kept small.<br/>
|
||||||
<b>Cumulative treshold:</b> If we add the maximum of red, green, blue values of every pixel in the sample and they total more than this, the frame is bright enough.<br/>
|
<b>Cumulative threshold:</b> If we add the maximum of red, green, blue values of every pixel in the sample and they total more than this, the frame is bright enough.<br/>
|
||||||
<b>Black pixel treshold:</b> If more than this fraction of pixels from the sample are "black", we consider the frame black. This overrules cumulative treshold.
|
<b>Black pixel threshold:</b> If more than this fraction of pixels from the sample are "black", we consider the frame black. This overrules cumulative threshold.
|
||||||
</div>
|
</div>
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
@ -309,17 +309,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Cumulative treshold:
|
Cumulative threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.blackframe.cumulativeTreshold"
|
v-model="settings.active.arDetect.blackframe.cumulativeThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Black pixel treshold:
|
Black pixel threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type=""
|
<input type=""
|
||||||
@ -335,8 +335,8 @@
|
|||||||
Options in this section govern edge detection.<br/>
|
Options in this section govern edge detection.<br/>
|
||||||
<b>Sample width</b> — 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
|
<b>Sample width</b> — 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.<br/>
|
amount of non-black pixels.<br/>
|
||||||
<b>Detection treshold</b> — non-black sample mentioned above needs to contain at least this many non-black pixels.<br/>
|
<b>Detection threshold</b> — non-black sample mentioned above needs to contain at least this many non-black pixels.<br/>
|
||||||
<b>Single side confirmation treshold</b> — quorum needed to establish aspect ratio in case we manage to detect an edge only on one side of the video. (0-0.5)<br/>
|
<b>Single side confirmation threshold</b> — quorum needed to establish aspect ratio in case we manage to detect an edge only on one side of the video. (0-0.5)<br/>
|
||||||
<b>Logo threshold</b> — if edge candidate sits with count greater than this*all_samples, it can't be a logo or a watermark.<br/>
|
<b>Logo threshold</b> — if edge candidate sits with count greater than this*all_samples, it can't be a logo or a watermark.<br/>
|
||||||
<b>Ignore middle area</b> — When trying to detect area, ignore area between middle and canvasHeight * {this value} pixels towards the edge.<br/>
|
<b>Ignore middle area</b> — When trying to detect area, ignore area between middle and canvasHeight * {this value} pixels towards the edge.<br/>
|
||||||
<b>Detect limit</b> — stop search after finding a potential candidate in this many sample columns (%, 0-1)<br/>
|
<b>Detect limit</b> — stop search after finding a potential candidate in this many sample columns (%, 0-1)<br/>
|
||||||
@ -354,31 +354,31 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Detection treshold (px):
|
Detection threshold (px):
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.edgeDetection.detectionTreshold"
|
v-model="settings.active.arDetect.edgeDetection.detectionThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Single side confirmation treshold:
|
Single side confirmation threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input
|
<input
|
||||||
v-model="settings.active.arDetect.edgeDetection.singleSideConfirmationTreshold"
|
v-model="settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row row-padding" v-if="showAdvancedOptions">
|
<div class="flex flex-row row-padding" v-if="showAdvancedOptions">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Logo treshold:
|
Logo threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input
|
<input
|
||||||
v-model="settings.active.arDetect.edgeDetection.logoTreshold"
|
v-model="settings.active.arDetect.edgeDetection.logoThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -409,7 +409,7 @@
|
|||||||
Quick test to determine whether aspect ratio hasn't changed. Test is performed by taking two samples on each edge of the image —
|
Quick test to determine whether aspect ratio hasn't changed. Test is performed by taking two samples on each edge of the image —
|
||||||
one in the last row of the letterbox (blackbar), and one in the first row of the video (image).<br/>
|
one in the last row of the letterbox (blackbar), and one in the first row of the video (image).<br/>
|
||||||
<b>Ignore edge margin:</b> We don't take blackbar and image samples {width * this} many pixels from left and right edge.<br/>
|
<b>Ignore edge margin:</b> We don't take blackbar and image samples {width * this} many pixels from left and right edge.<br/>
|
||||||
<b>Image treshold:</b> If all pixels in blackbar are black and this fraction (0-1) of pixels in image are non-black, we presume that aspect ratio hasn't changed.<br/>
|
<b>Image threshold:</b> If all pixels in blackbar are black and this fraction (0-1) of pixels in image are non-black, we presume that aspect ratio hasn't changed.<br/>
|
||||||
<b>Edge tolerance (px):<b> I lied. Blackbar test happens this many pixels away from the last row of the letterbox.
|
<b>Edge tolerance (px):<b> I lied. Blackbar test happens this many pixels away from the last row of the letterbox.
|
||||||
</div>
|
</div>
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
@ -439,7 +439,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
v-model="settings.active.arDetect.canvasDimensions.guardLine.imageTestTreshold"
|
v-model="settings.active.arDetect.canvasDimensions.guardLine.imageTestThreshold"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -456,14 +456,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="showAdvancedOptions">
|
<div v-if="showAdvancedOptions">
|
||||||
<div class="label">Aspect ratio change treshold</div>
|
<div class="label">Aspect ratio change threshold</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
New and old aspect ratio must differ by at least this much (%, 1=100%) before we trigger aspect ratio correction.
|
New and old aspect ratio must differ by at least this much (%, 1=100%) before we trigger aspect ratio correction.
|
||||||
</div>
|
</div>
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Aspect ratio change treshold.
|
Aspect ratio change threshold.
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type=""
|
<input type=""
|
||||||
|
@ -98,18 +98,18 @@
|
|||||||
<b>Hybrid:</b> stretches the video to fit the player, but only if cropping didn't completely remove the black bars.<br/>
|
<b>Hybrid:</b> stretches the video to fit the player, but only if cropping didn't completely remove the black bars.<br/>
|
||||||
<b>Thin borders:</b> stretches only if the width of black borders after cropping is thin.
|
<b>Thin borders:</b> stretches only if the width of black borders after cropping is thin.
|
||||||
<br/>
|
<br/>
|
||||||
Treshold for thin borders can be defined below.
|
Threshold for thin borders can be defined below.
|
||||||
</div>
|
</div>
|
||||||
<div class="indent">
|
<div class="indent">
|
||||||
<div class="flex flex-row row-padding">
|
<div class="flex flex-row row-padding">
|
||||||
<div class="flex label-secondary">
|
<div class="flex label-secondary">
|
||||||
Thin border treshold:
|
Thin border threshold:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input type="number"
|
<input type="number"
|
||||||
step="any"
|
step="any"
|
||||||
:value="settings.active.stretch.conditionalDifferencePercent"
|
:value="settings.active.stretch.conditionalDifferencePercent"
|
||||||
@input="updateStretchTreshold($event.target.value)"
|
@input="updateStretchThreshold($event.target.value)"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -168,11 +168,11 @@ export default {
|
|||||||
this.settings.active.sites['@global'].stretch = mode;
|
this.settings.active.sites['@global'].stretch = mode;
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
},
|
},
|
||||||
updateStretchTreshold(newTreshold) {
|
updateStretchThreshold(newThreshold) {
|
||||||
if (!newTreshold || isNaN(newTreshold)) {
|
if (!newThreshold || isNaN(newThreshold)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.settings.active.stretch.conditionalDifferencePercent = newTreshold;
|
this.settings.active.stretch.conditionalDifferencePercent = newThreshold;
|
||||||
this.settings.save();
|
this.settings.save();
|
||||||
},
|
},
|
||||||
resetSettings() {
|
resetSettings() {
|
||||||
|
@ -17,7 +17,7 @@ var ui = {
|
|||||||
stretchSettings: {
|
stretchSettings: {
|
||||||
buttonContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global_stretch')),
|
buttonContainer: BaseElement.fromExisting(document.getElementById('_general_extension_global_stretch')),
|
||||||
buttons: [],
|
buttons: [],
|
||||||
thinBordersTresholdInput: document.getElementById('_general_extension_global_stretch_thin_borders_treshold_input')
|
thinBordersThresholdInput: document.getElementById('_general_extension_global_stretch_thin_borders_threshold_input')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -89,11 +89,11 @@
|
|||||||
<b>Hybrid:</b> stretches the video to fit the player, but only if cropping didn't completely remove the black bars.<br/>
|
<b>Hybrid:</b> stretches the video to fit the player, but only if cropping didn't completely remove the black bars.<br/>
|
||||||
<b>Thin borders:</b> stretches only if the width of black borders after cropping is thin.
|
<b>Thin borders:</b> stretches only if the width of black borders after cropping is thin.
|
||||||
<br/>
|
<br/>
|
||||||
Treshold for thin borders can be defined below.
|
Threshold for thin borders can be defined below.
|
||||||
</span>
|
</span>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<div class="flex flex-input-label">
|
<div class="flex flex-input-label">
|
||||||
Thin border treshold (%):
|
Thin border threshold (%):
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-input">
|
<div class="flex flex-input">
|
||||||
<input id="_general_extension_global_stretch_thin_borders_input" type="number">
|
<input id="_general_extension_global_stretch_thin_borders_input" type="number">
|
||||||
|
Loading…
Reference in New Issue
Block a user