diff --git a/src/core/bp-registry/custom/1.png b/src/core/bp-registry/custom/1.png new file mode 100755 index 00000000..7d4d4a75 Binary files /dev/null and b/src/core/bp-registry/custom/1.png differ diff --git a/src/core/bp-registry/registry.json b/src/core/bp-registry/registry.json index 36d9a316..15e1354b 100644 --- a/src/core/bp-registry/registry.json +++ b/src/core/bp-registry/registry.json @@ -1,4 +1,22 @@ { + "custom": [ + { + "fileName": "1.png", + "daemons": [ + ["55", "1C", "1C"], + ["1C", "1C"], + ["1C", "E9", "1C", "E9"] + ], + "grid": [ + "E9", "1C", "55", "1C", "55", + "1C", "1C", "55", "E9", "55", + "1C", "1C", "55", "E9", "1C", + "BD", "1C", "1C", "1C", "55", + "1C", "55", "1C", "55", "BD" + ], + "bufferSize": 7 + } + ], "1024x768": [ { "fileName": "1.png", diff --git a/src/core/ocr/base.ts b/src/core/ocr/base.ts index cdc01124..6890bc9b 100644 --- a/src/core/ocr/base.ts +++ b/src/core/ocr/base.ts @@ -128,12 +128,12 @@ export abstract class BreachProtocolFragment< const { width, height, left, top } = this.container.getCroppedBoundingBox(); return { - left: left + Math.round(p1.x * width), - top: top + Math.round(p1.y * height), + left: Math.round(p1.x * width + left), + top: Math.round(p1.y * height + top), width: Math.round((p2.x - p1.x) * width), height: Math.round((p2.y - p1.y) * height), - outerWidth: width + 2 * left, - outerHeight: height + 2 * top, + outerWidth: Math.round(2 * left + width), + outerHeight: Math.round(2 * top + height), innerWidth: width, innerHeight: height, } as BreachProtocolFragmentBoundingBox; diff --git a/src/core/ocr/ocr.test.ts b/src/core/ocr/ocr.test.ts index a50759ab..3925c8f6 100644 --- a/src/core/ocr/ocr.test.ts +++ b/src/core/ocr/ocr.test.ts @@ -23,6 +23,7 @@ interface RegistryEntry { } type Resolution = + | 'custom' | '1024x768' | '1920x1080' | '2560x1440' @@ -184,6 +185,13 @@ describe('ocr', () => { await BreachProtocolOCRFragment.terminateScheduler(); }); + it.each(getRegistryFor('custom'))( + 'should correctly ocr custom resolution/%s', + async (f: string, entry: RegistryEntry) => { + await compareOcrToJson(entry, 'custom'); + } + ); + it.each(getRegistryFor('1024x768'))( 'should correctly ocr 1024x768/%s', async (f: string, entry: RegistryEntry) => {