diff --git a/src/bp-registry/3440x1440/1.png b/src/bp-registry/3440x1440/1.png new file mode 100755 index 00000000..71edcb8d Binary files /dev/null and b/src/bp-registry/3440x1440/1.png differ diff --git a/src/bp-registry/registry.json b/src/bp-registry/registry.json index a4883861..a91104ec 100644 --- a/src/bp-registry/registry.json +++ b/src/bp-registry/registry.json @@ -368,6 +368,27 @@ "bufferSize": 7 } ], + "3440x1440": [ + { + "fileName": "1.png", + "daemons": [ + ["BD", "BD"], + ["1C", "1C"], + ["1C", "FF"], + ["FF", "1C"] + ], + "grid": [ + "FF", "7A", "55", "FF", "55", "7A", "FF", + "7A", "1C", "1C", "E9", "1C", "BD", "1C", + "7A", "55", "1C", "1C", "E9", "1C", "7A", + "7A", "55", "7A", "E9", "BD", "BD", "BD", + "55", "1C", "FF", "E9", "1C", "1C", "FF", + "7A", "1C", "1C", "7A", "E9", "1C", "1C", + "FF", "7A", "E9", "1C", "55", "1C", "1C" + ], + "bufferSize": 8 + } + ], "3840x2160": [ { "fileName": "1.png", diff --git a/src/core/ocr/base.ts b/src/core/ocr/base.ts index cbeaf82c..81e031e3 100644 --- a/src/core/ocr/base.ts +++ b/src/core/ocr/base.ts @@ -17,6 +17,8 @@ export interface BreachProtocolFragmentBoundingBox { top: number; outerWidth: number; outerHeight: number; + innerWidth: number; + innerHeight: number; } export class BreachProtocolFragmentResult { @@ -58,7 +60,6 @@ export abstract class BreachProtocolFragment { const { p1, p2 } = this; const { width, height, left, top } = this.container.getCroppedBoundingBox(); - // NOTE: this does not return cropped with and height! return { left: left + Math.round(p1.x * width), top: top + Math.round(p1.y * height), @@ -66,6 +67,8 @@ export abstract class BreachProtocolFragment { height: Math.round((p2.y - p1.y) * height), outerWidth: width + 2 * left, outerHeight: height + 2 * top, + innerWidth: width, + innerHeight: height, } as BreachProtocolFragmentBoundingBox; } } @@ -176,9 +179,9 @@ export abstract class BreachProtocolOCRFragment< /** Get closest treshold value for given resolution. */ protected getThreshold() { - const { height } = this.container.getCroppedBoundingBox(); + const { innerHeight } = this.boundingBox; const list = [...this.thresholds.keys()]; - const value = getClosest(height, list); + const value = getClosest(innerHeight, list); return this.thresholds.get(value); } diff --git a/src/core/ocr/buffer-size-trim.ts b/src/core/ocr/buffer-size-trim.ts index 914202c0..dfaa519d 100644 --- a/src/core/ocr/buffer-size-trim.ts +++ b/src/core/ocr/buffer-size-trim.ts @@ -58,9 +58,9 @@ export class BreachProtocolBufferSizeTrimFragment< } private async getBufferSizeFromPixels(width: number) { - const { outerWidth } = this.boundingBox; + const { innerWidth } = this.boundingBox; - let size = width / outerWidth; + let size = width / innerWidth; let bufferSize = 0; size -= 2 * this.padding; diff --git a/src/core/ocr/buffer-size.ts b/src/core/ocr/buffer-size.ts index 5f096535..751ed9e3 100644 --- a/src/core/ocr/buffer-size.ts +++ b/src/core/ocr/buffer-size.ts @@ -172,8 +172,8 @@ export class BreachProtocolBufferSizeFragment extends BreachProtocolFragment< } private getBufferSizeFromPixels(pixels: Buffer) { - const { width, outerWidth } = this.boundingBox; - let size = this.getSizeOfBufferBox(pixels, width) / outerWidth; + const { width, innerWidth } = this.boundingBox; + let size = this.getSizeOfBufferBox(pixels, width) / innerWidth; let bufferSize = 0; size -= 2 * this.padding; diff --git a/src/core/ocr/ocr.test.ts b/src/core/ocr/ocr.test.ts index 014f333c..d28c0331 100644 --- a/src/core/ocr/ocr.test.ts +++ b/src/core/ocr/ocr.test.ts @@ -17,7 +17,7 @@ interface RegistryEntry { bufferSize: BufferSize; } -type Resolution = '1920x1080' | '2560x1440' | '3840x2160'; +type Resolution = '1920x1080' | '2560x1440' | '3440x1440' | '3840x2160'; type Registry = Record; describe('image container', () => { @@ -188,6 +188,13 @@ describe('ocr', () => { } ); + it.each(getRegistryFor('3440x1440'))( + 'should correctly ocr 3440x1440/%s', + async (f: string, entry: RegistryEntry) => { + await compareOcrToJson(entry, '3440x1440'); + } + ); + it.each(getRegistryFor('3840x2160'))( 'should correctly ocr 3840x2160/%s', async (f: string, entry: RegistryEntry) => {