2024-10-19 16:04:20 +02:00
|
|
|
import { AardSettings } from '../../../../common/interfaces/SettingsInterface'
|
2025-10-12 22:03:55 +02:00
|
|
|
import { AardUncertainReason } from '../enums/aard-letterbox-uncertain-reason.enum'
|
|
|
|
|
import { LetterboxOrientation } from '../enums/letterbox-orientation.enum'
|
|
|
|
|
|
|
|
|
|
export interface AardTestResult_SubtitleRegion {
|
|
|
|
|
firstBlank: number,
|
|
|
|
|
lastBlank: number,
|
|
|
|
|
firstSubtitle: number,
|
|
|
|
|
lastSubtitle: number,
|
|
|
|
|
firstImage: number,
|
|
|
|
|
lastImage: number
|
|
|
|
|
}
|
2024-10-19 16:04:20 +02:00
|
|
|
|
2024-10-14 00:28:13 +02:00
|
|
|
export interface AardTestResults {
|
|
|
|
|
isFinished: boolean,
|
|
|
|
|
lastStage: number,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxOrientation: LetterboxOrientation,
|
|
|
|
|
lastValidLetterboxOrientation: LetterboxOrientation,
|
|
|
|
|
subtitleDetected: boolean,
|
2024-10-14 00:28:13 +02:00
|
|
|
blackLevel: number, // is cumulative
|
|
|
|
|
blackThreshold: number, // is cumulative
|
|
|
|
|
guardLine: {
|
|
|
|
|
top: number, // is cumulative
|
|
|
|
|
bottom: number, // is cumulative
|
|
|
|
|
invalidated: boolean,
|
2024-11-13 01:45:45 +01:00
|
|
|
cornerViolated: [boolean, boolean, boolean, boolean],
|
|
|
|
|
cornerPixelsViolated: [0,0,0,0]
|
2024-10-14 00:28:13 +02:00
|
|
|
},
|
|
|
|
|
imageLine: {
|
|
|
|
|
top: number, // is cumulative
|
|
|
|
|
bottom: number, // is cumulative
|
|
|
|
|
invalidated: boolean
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
|
|
|
|
aspectRatioCheck: {
|
|
|
|
|
topRows: [number, number, number],
|
|
|
|
|
topQuality: [number, number, number],
|
|
|
|
|
bottomRows: [number, number, number],
|
|
|
|
|
bottomQuality: [number, number, number],
|
|
|
|
|
topCandidate: number,
|
2024-10-21 01:08:03 +02:00
|
|
|
topCandidateQuality: number,
|
|
|
|
|
bottomCandidate: number,
|
2024-11-13 01:45:45 +01:00
|
|
|
bottomCandidateDistance: number,
|
2024-10-21 01:08:03 +02:00
|
|
|
bottomCandidateQuality: number,
|
2024-12-31 02:50:33 +01:00
|
|
|
topRowsDifferenceMatrix: [number, number, number],
|
|
|
|
|
bottomRowsDifferenceMatrix: [number, number, number],
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
2024-10-21 01:08:03 +02:00
|
|
|
aspectRatioUncertain: boolean,
|
2024-12-31 02:50:33 +01:00
|
|
|
topRowUncertain: boolean,
|
|
|
|
|
bottomRowUncertain: boolean,
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUpdated: boolean,
|
2024-12-31 02:50:33 +01:00
|
|
|
activeAspectRatio: number, // is cumulative
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxSize: number,
|
2024-10-21 01:08:03 +02:00
|
|
|
letterboxOffset: number,
|
2024-10-19 16:04:20 +02:00
|
|
|
logoDetected: [boolean, boolean, boolean, boolean]
|
2025-10-12 22:03:55 +02:00
|
|
|
aspectRatioInvalid: boolean,
|
|
|
|
|
subtitleScan: {
|
|
|
|
|
top: number,
|
|
|
|
|
bottom: number,
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
top: AardTestResult_SubtitleRegion,
|
|
|
|
|
bottom: AardTestResult_SubtitleRegion
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
aspectRatioUncertainReason?: AardUncertainReason,
|
|
|
|
|
aspectRatioUncertainEdges: number,
|
|
|
|
|
aspectRatioInvalidReason?: string,
|
2024-10-14 00:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-19 16:04:20 +02:00
|
|
|
export function initAardTestResults(settings: AardSettings): AardTestResults {
|
2024-10-14 00:28:13 +02:00
|
|
|
return {
|
|
|
|
|
isFinished: true,
|
|
|
|
|
lastStage: 0,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxOrientation: LetterboxOrientation.NotKnown,
|
|
|
|
|
lastValidLetterboxOrientation: LetterboxOrientation.NotKnown,
|
2024-10-19 16:04:20 +02:00
|
|
|
blackLevel: settings.blackLevels.defaultBlack,
|
2024-10-14 00:28:13 +02:00
|
|
|
blackThreshold: 16,
|
|
|
|
|
guardLine: {
|
|
|
|
|
top: -1,
|
|
|
|
|
bottom: -1,
|
|
|
|
|
invalidated: false,
|
2024-11-13 01:45:45 +01:00
|
|
|
cornerViolated: [false, false, false, false],
|
|
|
|
|
cornerPixelsViolated: [0,0,0,0]
|
2024-10-14 00:28:13 +02:00
|
|
|
},
|
|
|
|
|
imageLine: {
|
|
|
|
|
top: -1,
|
|
|
|
|
bottom: -1,
|
|
|
|
|
invalidated: false,
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
|
|
|
|
aspectRatioCheck: {
|
|
|
|
|
topRows: [-1, -1, -1],
|
|
|
|
|
topQuality: [0, 0, 0],
|
|
|
|
|
bottomRows: [-1, -1, -1],
|
|
|
|
|
bottomQuality: [0, 0, 0],
|
|
|
|
|
topCandidate: 0,
|
2024-10-21 01:08:03 +02:00
|
|
|
topCandidateQuality: 0,
|
|
|
|
|
bottomCandidate: 0,
|
2024-11-13 01:45:45 +01:00
|
|
|
bottomCandidateDistance: 0,
|
2024-10-21 01:08:03 +02:00
|
|
|
bottomCandidateQuality: 0,
|
2024-12-31 02:50:33 +01:00
|
|
|
topRowsDifferenceMatrix: [0, 0, 0],
|
|
|
|
|
bottomRowsDifferenceMatrix: [0, 0, 0],
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUncertain: false,
|
2025-10-12 22:03:55 +02:00
|
|
|
aspectRatioUncertainEdges: 0,
|
2024-12-31 02:50:33 +01:00
|
|
|
topRowUncertain: false,
|
|
|
|
|
bottomRowUncertain: false,
|
2025-10-12 22:03:55 +02:00
|
|
|
subtitleDetected: false,
|
|
|
|
|
subtitleScan: {
|
|
|
|
|
top: -1,
|
|
|
|
|
bottom: -1,
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
top: {
|
|
|
|
|
firstBlank: -1,
|
|
|
|
|
lastBlank: -1,
|
|
|
|
|
firstSubtitle: -1,
|
|
|
|
|
lastSubtitle: -1,
|
|
|
|
|
firstImage: -1,
|
|
|
|
|
lastImage: -1
|
|
|
|
|
},
|
|
|
|
|
bottom: {
|
|
|
|
|
firstBlank: -1,
|
|
|
|
|
lastBlank: -1,
|
|
|
|
|
firstSubtitle: -1,
|
|
|
|
|
lastSubtitle: -1,
|
|
|
|
|
firstImage: -1,
|
|
|
|
|
lastImage: -1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUpdated: false,
|
2024-12-31 02:50:33 +01:00
|
|
|
activeAspectRatio: 0,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxSize: 0,
|
2024-10-21 01:08:03 +02:00
|
|
|
letterboxOffset: 0,
|
2025-04-22 02:44:28 +02:00
|
|
|
logoDetected: [false, false, false, false],
|
|
|
|
|
aspectRatioInvalid: false,
|
2024-10-14 00:28:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-19 16:04:20 +02:00
|
|
|
|
2024-12-31 03:14:29 +01:00
|
|
|
export function resetGuardLine(results: AardTestResults) {
|
|
|
|
|
results.guardLine.top = -1;
|
|
|
|
|
results.guardLine.bottom = -1;
|
|
|
|
|
results.imageLine.invalidated = false;
|
|
|
|
|
results.guardLine.invalidated = false;
|
|
|
|
|
results.guardLine.cornerViolated[0] = false;
|
|
|
|
|
results.guardLine.cornerViolated[1] = false;
|
|
|
|
|
results.guardLine.cornerViolated[2] = false;
|
|
|
|
|
results.guardLine.cornerViolated[3] = false;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[0] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[1] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[2] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[3] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 16:04:20 +02:00
|
|
|
export function resetAardTestResults(results: AardTestResults): void {
|
|
|
|
|
results.isFinished = false;
|
|
|
|
|
results.lastStage = 0;
|
2024-11-07 02:26:19 +01:00
|
|
|
results.imageLine.invalidated = false;
|
|
|
|
|
results.guardLine.invalidated = false;
|
2024-11-13 01:45:45 +01:00
|
|
|
results.guardLine.cornerViolated[0] = false;
|
|
|
|
|
results.guardLine.cornerViolated[1] = false;
|
|
|
|
|
results.guardLine.cornerViolated[2] = false;
|
|
|
|
|
results.guardLine.cornerViolated[3] = false;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[0] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[1] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[2] = 0;
|
|
|
|
|
results.guardLine.cornerPixelsViolated[3] = 0;
|
2024-12-31 02:50:33 +01:00
|
|
|
// results.letterboxWidth = 0;
|
|
|
|
|
// results.letterboxOffset = 0;
|
2024-10-22 23:43:25 +02:00
|
|
|
results.aspectRatioUpdated = false;
|
2024-12-30 23:02:55 +01:00
|
|
|
results.aspectRatioUncertainReason = null;
|
2024-12-31 02:50:33 +01:00
|
|
|
results.topRowUncertain = false;
|
|
|
|
|
results.bottomRowUncertain = false;
|
2025-04-22 02:44:28 +02:00
|
|
|
results.aspectRatioInvalid = false;
|
2025-10-12 22:03:55 +02:00
|
|
|
results.letterboxOrientation = LetterboxOrientation.NotKnown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function resetSubtitleScanResults(results: AardTestResults): void {
|
|
|
|
|
results.subtitleScan.top = -1;
|
|
|
|
|
results.subtitleScan.bottom = -1;
|
|
|
|
|
|
|
|
|
|
results.subtitleScan.regions.top.firstBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.top.firstSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.top.firstImage = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastImage = -1;
|
|
|
|
|
|
|
|
|
|
results.subtitleScan.regions.bottom.firstBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.firstSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.firstImage = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastImage = -1;
|
2024-10-19 16:04:20 +02:00
|
|
|
}
|
2025-10-12 22:03:55 +02:00
|
|
|
|