Skip to main content

OCR 기능

딸깍문서는 Claude Vision을 활용하여 이미지에서 텍스트를 추출하는 OCR(광학 문자 인식) 기능을 제공합니다.

개요

Claude Vision API를 사용하여 이미지나 PDF에서 텍스트를 정확하게 추출합니다. 특히 한국어, 영어, 터키어 등 다양한 언어의 특수 문자를 정확하게 인식합니다.

지원 형식

이미지 형식

형식MIME 타입지원
PNGimage/png
JPEGimage/jpeg
GIFimage/gif
WebPimage/webp

지원 언어

  • 한국어 (가-힣)
  • 영어 (A-Z, a-z)
  • 터키어 (İ, ı, Ğ, ğ, Ş, ş, Ç, ç 등)
  • 기타 유니코드 언어

사용 방법

단일 이미지 OCR

const response = await fetch("/api/ocr/claude-vision", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
image_base64: "base64_encoded_image",
media_type: "image/png",
language: "ko",
}),
});

const { text } = await response.json();

배치 OCR

여러 이미지를 한 번에 처리:

const response = await fetch("/api/ocr/claude-vision-batch", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
images: [
{ image_base64: "...", media_type: "image/png" },
{ image_base64: "...", media_type: "image/jpeg" },
],
language: "ko",
}),
});

const { results } = await response.json();

API 상세

요청 형식

interface OCRRequest {
image_base64: string;
media_type: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
language?: string;
instructions?: string;
}

응답 형식

interface OCRResponse {
text: string;
confidence?: string;
language_detected?: string;
}

OCR 프롬프트

Claude에게 전달되는 OCR 지시사항:

You are an expert OCR system. Extract ALL text from this image exactly as it appears.

IMPORTANT RULES:
1. Preserve the EXACT characters as they appear, including:
- Turkish characters: İ, ı, Ğ, ğ, Ş, ş, Ç, ç, Ö, ö, Ü, ü
- Korean characters: 가-힣
- Special characters and punctuation
2. Maintain the original formatting (line breaks, spacing)
3. If there are tables, preserve the table structure using | separators
4. Do NOT translate or modify any text
5. Output ONLY the extracted text, nothing else

특수 용도

영역 OCR

PDF의 특정 영역만 OCR 처리:

const response = await fetch("/api/pdf/ocr-region", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
pdf_base64: "...",
page: 1,
region: {
x: 100,
y: 200,
width: 300,
height: 50,
},
}),
});

테이블 인식

테이블 구조가 있는 이미지의 경우 | 구분자로 구조를 보존합니다:

| 이름 | 나이 | 직업 |
| 홍길동 | 30 | 개발자 |
| 김철수 | 25 | 디자이너 |

성능 최적화

이미지 전처리

더 나은 OCR 결과를 위해:

  1. 해상도: 최소 150 DPI
  2. 대비: 텍스트와 배경 간 명확한 대비
  3. 크기: 너무 작은 텍스트는 확대

배치 처리

많은 이미지를 처리할 때는 배치 API를 사용:

  • 단일 요청으로 여러 이미지 처리
  • API 호출 횟수 감소
  • 전체 처리 시간 단축

에러 처리

일반적인 오류

오류원인해결
Invalid media_type지원하지 않는 이미지 형식PNG, JPEG, GIF, WebP 사용
Image too large이미지 크기 초과이미지 리사이즈
OCR failed텍스트 인식 실패이미지 품질 개선

제한사항

항목제한
최대 이미지 크기20MB
최대 해상도8000 x 8000
배치 최대 이미지 수10개

활용 사례

문서 디지털화

스캔된 문서를 편집 가능한 텍스트로 변환:

flowchart LR
A[스캔 문서] --> B[OCR 처리]
B --> C[텍스트 추출]
C --> D[문서 편집기]
D --> E[편집/수정]

PDF 참고자료

PDF 내용을 텍스트로 추출하여 AI 참고자료로 활용:

flowchart LR
A[PDF 업로드] --> B[페이지 이미지화]
B --> C[OCR 처리]
C --> D[텍스트 저장]
D --> E[AI 참고자료]

다음 단계