Move some last remaining enums to typescript

This commit is contained in:
Tamius Han 2021-03-06 04:01:47 +01:00
parent 4354393f79
commit 6c59c009e5
8 changed files with 33 additions and 33 deletions

View File

@ -701,7 +701,7 @@ class ArDetector {
// that we will cut too much, we rather avoid doing anything at all. There's gonna be a next chance. // that we will cut too much, we rather avoid doing anything at all. There's gonna be a next chance.
try{ try{
if(guardLineOut.blackbarFail || guardLineOut.imageFail){ if(guardLineOut.blackbarFail || guardLineOut.imageFail){
if(this.edgeDetector.findBars(imageData, null, EdgeDetectPrimaryDirection.HORIZONTAL).status === 'ar_known'){ if(this.edgeDetector.findBars(imageData, null, EdgeDetectPrimaryDirection.Horizontal).status === 'ar_known'){
if(guardLineOut.blackbarFail){ if(guardLineOut.blackbarFail){
@ -724,14 +724,14 @@ class ArDetector {
// blackSamples -> {res_top, res_bottom} // blackSamples -> {res_top, res_bottom}
let edgePost = this.edgeDetector.findBars(imageData, sampleCols, EdgeDetectPrimaryDirection.VERTICAL, EdgeDetectQuality.IMPROVED, guardLineOut, bfanalysis); let edgePost = this.edgeDetector.findBars(imageData, sampleCols, EdgeDetectPrimaryDirection.Vertical, EdgeDetectQuality.Improved, guardLineOut, bfanalysis);
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost); this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] edgeDetector returned this\n`, "color: #aaf", edgePost);
if (edgePost.status !== EdgeStatus.AR_KNOWN){ if (edgePost.status !== EdgeStatus.ARKnown){
// rob ni bil zaznan, zato ne naredimo ničesar. // rob ni bil zaznan, zato ne naredimo ničesar.
// no edge was detected. Let's leave things as they were // no edge was detected. Let's leave things as they were
this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Edge wasn't detected with findBars`, "color: #fa3", edgePost, "EdgeStatus.AR_KNOWN:", EdgeStatus.AR_KNOWN); this.logger.log('info', 'arDetect_verbose', `%c[ArDetect::frameCheck] Edge wasn't detected with findBars`, "color: #fa3", edgePost, "EdgeStatus.AR_KNOWN:", EdgeStatus.ARKnown);
this.clearImageData(imageData); this.clearImageData(imageData);
return; return;

View File

@ -43,14 +43,14 @@ 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 {
fastCandidates = this.findCandidates(image, sampleCols, guardLineOut); fastCandidates = this.findCandidates(image, sampleCols, guardLineOut);
if (! this.isValidSample(fastCandidates)) { if (! this.isValidSample(fastCandidates)) {
return {status: EdgeStatus.AR_UNKNOWN}; return {status: EdgeStatus.ARUnknown};
} }
// if(quality == EdgeDetectQuality.FAST){ // if(quality == EdgeDetectQuality.FAST){
// edges = fastCandidates; // todo: processing // edges = fastCandidates; // todo: processing
@ -60,10 +60,10 @@ class EdgeDetect{
// } // }
} catch (e) { } catch (e) {
this.logger.log('error', 'arDetect', '%c[EdgeDetect::findBars] find bars failed.', 'background: #f00, color: #000', e); this.logger.log('error', 'arDetect', '%c[EdgeDetect::findBars] find bars failed.', 'background: #f00, color: #000', e);
return {status: EdgeStatus.AR_UNKNOWN} return {status: EdgeStatus.ARUnknown}
} }
} else { } else {
bars = this.pillarTest(image) ? {status: EdgeStatus.AR_KNOWN} : {status: EdgeStatus.AR_UNKNOWN}; bars = this.pillarTest(image) ? {status: EdgeStatus.ARKnown} : {status: EdgeStatus.ARUnknown};
} }
return bars; return bars;
@ -409,7 +409,7 @@ class EdgeDetect{
if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold if (edgesTop[0].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| ( edgesTop[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ){ || ( edgesTop[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ){
return { return {
status: EdgeStatus.AR_KNOWN, status: EdgeStatus.ARKnown,
blackbarWidth: blackbarWidth, blackbarWidth: blackbarWidth,
guardLineTop: edgesTop[0].distance, guardLineTop: edgesTop[0].distance,
guardLineBottom: edgesBottom[0].absolute, guardLineBottom: edgesBottom[0].absolute,
@ -443,7 +443,7 @@ class EdgeDetect{
if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold if (edgesTop[i].count + edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| (edgesTop[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ) { || (edgesTop[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[0].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold) ) {
return { return {
status: EdgeStatus.AR_KNOWN, status: EdgeStatus.ARKnown,
blackbarWidth: blackbarWidth, blackbarWidth: blackbarWidth,
guardLineTop: edgesTop[i].distance, guardLineTop: edgesTop[i].distance,
guardLineBottom: edgesBottom[0].absolute, guardLineBottom: edgesBottom[0].absolute,
@ -474,7 +474,7 @@ class EdgeDetect{
if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold if (edgesTop[0].count + edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold
|| (edgesTop[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold)) { || (edgesTop[0].count > this.settings.active.arDetect.edgeDetection.singleSideConfirmationThreshold && edgesBottom[i].count > this.settings.active.arDetect.edgeDetection.confirmationThreshold)) {
return { return {
status: EdgeStatus.AR_KNOWN, status: EdgeStatus.ARKnown,
blackbarWidth: blackbarWidth, blackbarWidth: blackbarWidth,
guardLineTop: edgesTop[0].distance, guardLineTop: edgesTop[0].distance,
guardLineBottom: edgesBottom[i].absolute, guardLineBottom: edgesBottom[i].absolute,
@ -500,7 +500,7 @@ class EdgeDetect{
for(let edge of edgesBottom){ for(let edge of edgesBottom){
if(edge.count >= edgeDetectionThreshold) if(edge.count >= edgeDetectionThreshold)
return { return {
status: EdgeStatus.AR_KNOWN, status: EdgeStatus.ARKnown,
blackbarWidth: edge.distance, blackbarWidth: edge.distance,
guardLineTop: null, guardLineTop: null,
guardLineBottom: edge.bottom, guardLineBottom: edge.bottom,
@ -514,7 +514,7 @@ class EdgeDetect{
for(let edge of edgesTop){ for(let edge of edgesTop){
if(edge.count >= edgeDetectionThreshold) if(edge.count >= edgeDetectionThreshold)
return { return {
status: EdgeStatus.AR_KNOWN, status: EdgeStatus.ARKnown,
blackbarWidth: edge.distance, blackbarWidth: edge.distance,
guardLineTop: edge.top, guardLineTop: edge.top,
guardLineBottom: null, guardLineBottom: null,
@ -527,7 +527,7 @@ class EdgeDetect{
} }
// če pridemo do sem, nam ni uspelo nič. Razmerje stranic ni znano // če pridemo do sem, nam ni uspelo nič. Razmerje stranic ni znano
// if we reach this bit, we have failed in determining aspect ratio. It remains unknown. // if we reach this bit, we have failed in determining aspect ratio. It remains unknown.
return {status: EdgeStatus.AR_UNKNOWN} return {status: EdgeStatus.ARUnknown}
} }
pillarTest(image){ pillarTest(image){

View File

@ -1,6 +0,0 @@
var EdgeDetectPrimaryDirection = Object.freeze({
VERTICAL: 0,
HORIZONTAL: 1
});
export default EdgeDetectPrimaryDirection;

View File

@ -0,0 +1,6 @@
enum EdgeDetectPrimaryDirection {
Vertical = 0,
Horizontal = 1
};
export default EdgeDetectPrimaryDirection;

View File

@ -1,6 +0,0 @@
var EdgeDetectQuality = Object.freeze({
FAST: 0,
IMPROVED: 1
});
export default EdgeDetectQuality;

View File

@ -0,0 +1,6 @@
enum EdgeDetectQuality {
Fast = 0,
Improved = 1
};
export default EdgeDetectQuality;

View File

@ -1,6 +0,0 @@
var EdgeStatus = Object.freeze({
AR_UNKNOWN: 0,
AR_KNOWN: 1,
});
export default EdgeStatus;

View File

@ -0,0 +1,6 @@
enum EdgeStatus {
ARUnknown = 0,
ARKnown = 1,
};
export default EdgeStatus;