Fix problems in ArDetector and related functions
This commit is contained in:
parent
a3bd8a8b7e
commit
8475340999
@ -672,7 +672,9 @@ class ArDetector {
|
|||||||
// otherwise we continue. We add blackbar violations to the list of the cols
|
// otherwise we continue. We add blackbar violations to the list of the cols
|
||||||
// we'll sample and sort them
|
// we'll sample and sort them
|
||||||
if (guardLineOut.blackbarFail) {
|
if (guardLineOut.blackbarFail) {
|
||||||
sampleCols.concat(guardLineOut.offenders).sort((a, b) => a > b);
|
sampleCols.concat(guardLineOut.offenders).sort(
|
||||||
|
(a: number, b: number) => a - b
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're in fallback mode and blackbar test failed, we restore CSS and quit
|
// if we're in fallback mode and blackbar test failed, we restore CSS and quit
|
||||||
|
@ -43,7 +43,7 @@ class EdgeDetect{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findBars(image, sampleCols, direction = EdgeDetectPrimaryDirection.VERTICAL, quality = EdgeDetectQuality.IMPROVED, guardLineOut, blackFrameAnalysis){
|
findBars(image, sampleCols, direction = EdgeDetectPrimaryDirection.VERTICAL, quality = EdgeDetectQuality.IMPROVED, guardLineOut?, blackFrameAnalysis?){
|
||||||
let fastCandidates, edgeCandidates, bars;
|
let fastCandidates, edgeCandidates, bars;
|
||||||
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
if (direction == EdgeDetectPrimaryDirection.VERTICAL) {
|
||||||
try {
|
try {
|
||||||
@ -863,7 +863,7 @@ class EdgeDetect{
|
|||||||
let tmpI;
|
let tmpI;
|
||||||
let lastTmpI = 0;
|
let lastTmpI = 0;
|
||||||
let edgeDetectCount = 0;
|
let edgeDetectCount = 0;
|
||||||
for(const c in colsOut) {
|
for(const c of colsOut) {
|
||||||
c.diffs = [];
|
c.diffs = [];
|
||||||
}
|
}
|
||||||
if (reverseSearchDirection) {
|
if (reverseSearchDirection) {
|
||||||
@ -1010,7 +1010,7 @@ class EdgeDetect{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
for(let i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
||||||
for(let c = 0; c < colsIn.length; c++){
|
for(let c = 0; c < colsIn.length; c++){
|
||||||
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
if (colsIn[c].blackFound && colsIn[c].imageFound) {
|
||||||
// če smo našli obe točki, potem ne pregledujemo več.
|
// če smo našli obe točki, potem ne pregledujemo več.
|
||||||
@ -1066,18 +1066,18 @@ class EdgeDetect{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_columnTest(image, top, bottom, colsIn, colsOut, reverseSearchDirection){
|
_columnTest(image, top: number, bottom: number, colsIn, colsOut, reverseSearchDirection){
|
||||||
var tmpI;
|
let tmpI;
|
||||||
if(reverseSearchDirection){
|
if(reverseSearchDirection){
|
||||||
for(var i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
for(let i = bottom - this.conf.canvasImageDataRowLength; i >= top; i-= this.conf.canvasImageDataRowLength){
|
||||||
for(var col of colsIn){
|
for(const col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarThreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
image[tmpI + 1] > this.blackbarThreshold ||
|
image[tmpI + 1] > this.blackbarThreshold ||
|
||||||
image[tmpI + 2] > this.blackbarThreshold ){
|
image[tmpI + 2] > this.blackbarThreshold ){
|
||||||
|
|
||||||
var bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
const bottom = (i / this.conf.canvasImageDataRowLength) + 1;
|
||||||
colsOut.push({
|
colsOut.push({
|
||||||
col: col,
|
col: col,
|
||||||
bottom: bottom
|
bottom: bottom
|
||||||
@ -1089,8 +1089,8 @@ class EdgeDetect{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(var i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
for(let i = top; i < bottom; i+= this.conf.canvasImageDataRowLength){
|
||||||
for(var col of colsIn){
|
for(const col of colsIn){
|
||||||
tmpI = i + (col << 2);
|
tmpI = i + (col << 2);
|
||||||
|
|
||||||
if( image[tmpI] > this.blackbarThreshold ||
|
if( image[tmpI] > this.blackbarThreshold ||
|
||||||
@ -1194,9 +1194,9 @@ class EdgeDetect{
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
_imageTest(image, start, end, sampleOffset, edgeCandidates){
|
_imageTest(image, start, end, sampleOffset, edgeCandidates){
|
||||||
var detections = 0;
|
let detections = 0;
|
||||||
|
|
||||||
for (var i = start; i < end; i += 4){
|
for (let i = start; i < end; i += 4){
|
||||||
if (image[i ] > this.blackbarThreshold ||
|
if (image[i ] > this.blackbarThreshold ||
|
||||||
image[i+1] > this.blackbarThreshold ||
|
image[i+1] > this.blackbarThreshold ||
|
||||||
image[i+2] > this.blackbarThreshold ){
|
image[i+2] > this.blackbarThreshold ){
|
||||||
|
Loading…
Reference in New Issue
Block a user