init
This commit is contained in:
22
frontend/dev_chatbot/OCRService.js
Normal file
22
frontend/dev_chatbot/OCRService.js
Normal 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;
|
||||
Reference in New Issue
Block a user