From fddc0490e381a4696200e86d3f5efb7b9c81bfa1 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Fri, 8 Nov 2024 16:33:28 -0800 Subject: [PATCH] Automatically align images for OCR (#384) --- frontend/api/api.ts | 7 ++++--- frontend/api/types/types.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/api/api.ts b/frontend/api/api.ts index 0e48b606..3bc2bea7 100644 --- a/frontend/api/api.ts +++ b/frontend/api/api.ts @@ -2,7 +2,7 @@ import { ImageToTextArgs, ImageToTextResponse, AlignImageArgs, AlignImageRespons const apiUrl = import.meta.env.VITE_API_URL || "http://localhost:8000/" -export const AlignImage = async (args: AlignImageArgs): Promise => { +export const AlignImage = async (args: AlignImageArgs): Promise => { const { sourceImage, templateImage } = args; const form = new URLSearchParams({ source_image: sourceImage, @@ -21,15 +21,16 @@ export const AlignImage = async (args: AlignImageArgs): Promise => { const { sourceImage, templateImage, fieldNames } = args; + const aligned_result = await AlignImage({sourceImage, templateImage}); const form = new URLSearchParams({ - source_image: sourceImage, + source_image: aligned_result["result"], segmentation_template: templateImage, labels: JSON.stringify(fieldNames), }); diff --git a/frontend/api/types/types.ts b/frontend/api/types/types.ts index 62131944..be71ecc0 100644 --- a/frontend/api/types/types.ts +++ b/frontend/api/types/types.ts @@ -13,7 +13,7 @@ export type ImageToTextResponse = { }; export type AlignImageResponse = { - [key: string]: [string, number]; + [key: string]: string; }; export interface ResultItem {