Fix issue with 1px letterbox in atuodetection
This commit is contained in:
parent
d7b3508f85
commit
dba9b054d4
@ -765,22 +765,34 @@ class ArDetector {
|
|||||||
if(Debug.debug && Debug.debugArDetect){
|
if(Debug.debug && Debug.debugArDetect){
|
||||||
console.log(`%c[ArDetect::frameCheck] Triggering aspect ration change! new ar: ${newAr}`, "color: #aaf");
|
console.log(`%c[ArDetect::frameCheck] Triggering aspect ration change! new ar: ${newAr}`, "color: #aaf");
|
||||||
}
|
}
|
||||||
this.processAr(newAr);
|
|
||||||
|
|
||||||
// we also know edges for guardline, so set them.
|
// we also know edges for guardline, so set them.
|
||||||
// we need to be mindful of fallbackMode though
|
// we need to be mindful of fallbackMode though
|
||||||
if (!this.fallbackMode) {
|
// if edges are okay and not invalid, we also
|
||||||
this.guardLine.setBlackbar({top: edgePost.guardLineTop, bottom: edgePost.guardLineBottom});
|
// allow automatic aspect ratio correction. If edges
|
||||||
} else {
|
// are bogus, we remain aspect ratio unchanged.
|
||||||
if (this.conf.player.dimensions){
|
try {
|
||||||
this.guardLine.setBlackbarManual({
|
if (!this.fallbackMode) {
|
||||||
top: this.settings.active.arDetect.fallbackMode.noTriggerZonePx,
|
// throws error if top/bottom are invalid
|
||||||
bottom: this.conf.player.dimensions.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1
|
this.guardLine.setBlackbar({top: edgePost.guardLineTop, bottom: edgePost.guardLineBottom});
|
||||||
},{
|
} else {
|
||||||
top: edgePost.guardLineTop + this.settings.active.arDetect.guardLine.edgeTolerancePx,
|
if (this.conf.player.dimensions){
|
||||||
bottom: edgePost.guardLineBottom - this.settings.active.arDetect.guardLine.edgeTolerancePx
|
this.guardLine.setBlackbarManual({
|
||||||
})
|
top: this.settings.active.arDetect.fallbackMode.noTriggerZonePx,
|
||||||
|
bottom: this.conf.player.dimensions.height - this.settings.active.arDetect.fallbackMode.noTriggerZonePx - 1
|
||||||
|
},{
|
||||||
|
top: edgePost.guardLineTop + this.settings.active.arDetect.guardLine.edgeTolerancePx,
|
||||||
|
bottom: edgePost.guardLineBottom - this.settings.active.arDetect.guardLine.edgeTolerancePx
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.processAr(newAr);
|
||||||
|
} catch (e) {
|
||||||
|
// edges weren't gucci, so we'll just reset
|
||||||
|
// the aspect ratio to defaults
|
||||||
|
this.guardline.reset();
|
||||||
|
this.conf.resizer.setAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()});
|
||||||
}
|
}
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@ -34,9 +34,7 @@ class GuardLine {
|
|||||||
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
|
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
|
||||||
// this removes any configs with invalid values or values that dont make sense
|
// this removes any configs with invalid values or values that dont make sense
|
||||||
if (bbTop < 0 || bbBottom >= this.conf.canvas.height ){
|
if (bbTop < 0 || bbBottom >= this.conf.canvas.height ){
|
||||||
console.log("%c[GuardLine::setBlackbar] INVALID SETTINGS IN GUARDLINE","background: #000; color: #fff")
|
throw "INVALID_SETTINGS_IN_GUARDLINE"
|
||||||
this.reset();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blackbar = {
|
this.blackbar = {
|
||||||
|
@ -247,91 +247,91 @@ class EdgeDetect{
|
|||||||
var bottomEdgeCount = 0;
|
var bottomEdgeCount = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const sample of samples.res_top){
|
for (const sample of samples.res_top){
|
||||||
blackEdgeViolation = false; // reset this
|
blackEdgeViolation = false; // reset this
|
||||||
|
|
||||||
// determine our bounds. Note that sample.col is _not_ corrected for imageData, but halfSample is
|
// determine our bounds. Note that sample.col is _not_ corrected for imageData, but halfSample is
|
||||||
sampleStart = (sample.col << 2) - this.halfSample;
|
sampleStart = (sample.col << 2) - this.halfSample;
|
||||||
|
|
||||||
if(sampleStart < 0)
|
if(sampleStart < 0)
|
||||||
sampleStart = 0;
|
sampleStart = 0;
|
||||||
|
|
||||||
sampleEnd = sampleStart + this.sampleWidthBase;
|
sampleEnd = sampleStart + this.sampleWidthBase;
|
||||||
if(sampleEnd > this.conf.canvasImageDataRowLength)
|
if (sampleEnd > this.conf.canvasImageDataRowLength)
|
||||||
sampleEnd = this.conf.canvasImageDataRowLength;
|
sampleEnd = this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
// calculate row offsets for imageData array
|
// calculate row offsets for imageData array
|
||||||
sampleRow_black = (sample.black - this.settings.active.arDetect.edgeDetection.edgeTolerancePx - 1) * this.conf.canvasImageDataRowLength;
|
sampleRow_black = (sample.black - this.settings.active.arDetect.edgeDetection.edgeTolerancePx - 1) * this.conf.canvasImageDataRowLength;
|
||||||
sampleRow_color = (sample.black + this.settings.active.arDetect.edgeDetection.edgeTolerancePx) * this.conf.canvasImageDataRowLength;
|
sampleRow_color = (sample.black + this.settings.active.arDetect.edgeDetection.edgeTolerancePx) * this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
// že ena kršitev črnega roba pomeni, da kandidat ni primeren
|
// že ena kršitev črnega roba pomeni, da kandidat ni primeren
|
||||||
// even a single black edge violation means the candidate is not an edge
|
// even a single black edge violation means the candidate is not an edge
|
||||||
loopEnd = sampleRow_black + sampleEnd;
|
loopEnd = sampleRow_black + sampleEnd;
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled){
|
if (Debug.debugCanvas.enabled){
|
||||||
blackEdgeViolation = this._blackbarTest_dbg(image, sampleRow_black + sampleStart, loopEnd);
|
blackEdgeViolation = this._blackbarTest_dbg(image, sampleRow_black + sampleStart, loopEnd);
|
||||||
} else {
|
} else {
|
||||||
blackEdgeViolation = this._blackbarTest(image, sampleRow_black + sampleStart, loopEnd);
|
blackEdgeViolation = this._blackbarTest(image, sampleRow_black + sampleStart, loopEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// če je bila črna črta skrunjena, preverimo naslednjega kandidata
|
||||||
|
// if we failed, we continue our search with the next candidate
|
||||||
|
if (blackEdgeViolation) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
detections = 0;
|
||||||
|
loopEnd = sampleRow_color + sampleEnd;
|
||||||
|
|
||||||
|
if (Debug.debugCanvas.enabled) {
|
||||||
|
this._imageTest_dbg(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesTop)
|
||||||
|
} else {
|
||||||
|
this._imageTest(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesTop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// če je bila črna črta skrunjena, preverimo naslednjega kandidata
|
for (const sample of samples.res_bottom){
|
||||||
// if we failed, we continue our search with the next candidate
|
blackEdgeViolation = false; // reset this
|
||||||
if (blackEdgeViolation) {
|
|
||||||
continue;
|
// determine our bounds. Note that sample.col is _not_ corrected for imageData, but this.halfSample is
|
||||||
|
sampleStart = (sample.col << 2) - this.halfSample;
|
||||||
|
|
||||||
|
if(sampleStart < 0)
|
||||||
|
sampleStart = 0;
|
||||||
|
|
||||||
|
sampleEnd = sampleStart + this.sampleWidthBase;
|
||||||
|
if(sampleEnd > this.conf.canvasImageDataRowLength)
|
||||||
|
sampleEnd = this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
|
// calculate row offsets for imageData array
|
||||||
|
sampleRow_black = (sample.black + this.settings.active.arDetect.edgeDetection.edgeTolerancePx + 1) * this.conf.canvasImageDataRowLength;
|
||||||
|
sampleRow_color = (sample.black - this.settings.active.arDetect.edgeDetection.edgeTolerancePx) * this.conf.canvasImageDataRowLength;
|
||||||
|
|
||||||
|
// že ena kršitev črnega roba pomeni, da kandidat ni primeren
|
||||||
|
// even a single black edge violation means the candidate is not an edge
|
||||||
|
loopEnd = sampleRow_black + sampleEnd;
|
||||||
|
|
||||||
|
if(Debug.debugCanvas.enabled){
|
||||||
|
blackEdgeViolation = this._blackbarTest_dbg(image, sampleRow_black + sampleStart, loopEnd);
|
||||||
|
} else {
|
||||||
|
blackEdgeViolation = this._blackbarTest(image, sampleRow_black + sampleStart, loopEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// če je bila črna črta skrunjena, preverimo naslednjega kandidata
|
||||||
|
// if we failed, we continue our search with the next candidate
|
||||||
|
if (blackEdgeViolation) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
detections = 0;
|
||||||
|
loopEnd = sampleRow_color + sampleEnd;
|
||||||
|
|
||||||
|
if(Debug.debugCanvas.enabled) {
|
||||||
|
this._imageTest_dbg(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesBottom);
|
||||||
|
} else {
|
||||||
|
this._imageTest(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesBottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
detections = 0;
|
|
||||||
loopEnd = sampleRow_color + sampleEnd;
|
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled) {
|
|
||||||
this._imageTest_dbg(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesTop)
|
|
||||||
} else {
|
|
||||||
this._imageTest(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesTop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const sample of samples.res_bottom){
|
|
||||||
blackEdgeViolation = false; // reset this
|
|
||||||
|
|
||||||
// determine our bounds. Note that sample.col is _not_ corrected for imageData, but this.halfSample is
|
|
||||||
sampleStart = (sample.col << 2) - this.halfSample;
|
|
||||||
|
|
||||||
if(sampleStart < 0)
|
|
||||||
sampleStart = 0;
|
|
||||||
|
|
||||||
sampleEnd = sampleStart + this.sampleWidthBase;
|
|
||||||
if(sampleEnd > this.conf.canvasImageDataRowLength)
|
|
||||||
sampleEnd = this.conf.canvasImageDataRowLength;
|
|
||||||
|
|
||||||
// calculate row offsets for imageData array
|
|
||||||
sampleRow_black = (sample.black + this.settings.active.arDetect.edgeDetection.edgeTolerancePx + 1) * this.conf.canvasImageDataRowLength;
|
|
||||||
sampleRow_color = (sample.black - this.settings.active.arDetect.edgeDetection.edgeTolerancePx) * this.conf.canvasImageDataRowLength;
|
|
||||||
|
|
||||||
// že ena kršitev črnega roba pomeni, da kandidat ni primeren
|
|
||||||
// even a single black edge violation means the candidate is not an edge
|
|
||||||
loopEnd = sampleRow_black + sampleEnd;
|
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled){
|
|
||||||
blackEdgeViolation = this._blackbarTest_dbg(image, sampleRow_black + sampleStart, loopEnd);
|
|
||||||
} else {
|
|
||||||
blackEdgeViolation = this._blackbarTest(image, sampleRow_black + sampleStart, loopEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
// če je bila črna črta skrunjena, preverimo naslednjega kandidata
|
|
||||||
// if we failed, we continue our search with the next candidate
|
|
||||||
if (blackEdgeViolation) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
detections = 0;
|
|
||||||
loopEnd = sampleRow_color + sampleEnd;
|
|
||||||
|
|
||||||
if(Debug.debugCanvas.enabled) {
|
|
||||||
this._imageTest_dbg(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesBottom);
|
|
||||||
} else {
|
|
||||||
this._imageTest(image, sampleRow_color + sampleStart, loopEnd, sample.black, edgeCandidatesBottom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("\n\nuwu fucky wucky:", e, "\n\n")
|
console.log("\n\nuwu fucky wucky:", e, "\n\n")
|
||||||
}
|
}
|
||||||
@ -623,7 +623,9 @@ class EdgeDetect{
|
|||||||
|
|
||||||
if (reverseSearchDirection) {
|
if (reverseSearchDirection) {
|
||||||
increment = -this.conf.canvasImageDataRowLength;
|
increment = -this.conf.canvasImageDataRowLength;
|
||||||
arrayStart = bottom - this.conf.canvasImageDataRowLength;
|
// don't subtract this.conf.canvasImageDataRowLength — it has already been accounted for
|
||||||
|
// when we calculated bottom and top
|
||||||
|
arrayStart = bottom;
|
||||||
arrayEnd = top;
|
arrayEnd = top;
|
||||||
|
|
||||||
// this is a hack so we get pointer-like things rather than values
|
// this is a hack so we get pointer-like things rather than values
|
||||||
|
Loading…
Reference in New Issue
Block a user