This commit is contained in:
dsyoon
2025-12-27 14:06:26 +09:00
parent 23f5388c56
commit 46460b77f8
33 changed files with 4600 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
// OCRService.js 브라우저에서 동작하는 간단 OCR 래퍼(Tesseract.js)
// -----------------------------------------------------------------------------
// 이미지 File 객체를 받아 한국어+영어 텍스트를 추출하여 반환한다.
// 주의: 브라우저 워커 기반이므로 큰 이미지·다중 호출 시 성능 이슈가 있을 수 있다.
// -----------------------------------------------------------------------------
import Tesseract from 'tesseract.js';
/**
* @param {File} imageFile - 이미지 파일 객체
* @returns {Promise<string>} 추출 텍스트 (trim 처리)
*/
const OCRService = async (imageFile) => {
try {
const { data: { text } } = await Tesseract.recognize(imageFile, 'kor+eng');
return text.trim();
} catch (e) {
return '';
}
};
export default OCRService;