IronOCR을 ChatGPT Codex와 함께 사용하는 방법
초기에 AI로 지원되는 OCR 시도에서 흔히 발생하는 문제는 개발자가 불완전한 스캔 가져오기 장치를 채팅에 붙여넣고 겉보기에 완전한 코드를 받았다가 나중에 다른 Tesseract 래퍼의 잘못된 합계나 구성 호출 오류를 발견하게 되는 것입니다. 이러한 오류는 다양한 필터, 언어 및 출력 형식을 갖춘 OCR 엔진이 있는 대형 API에서는 실수를 저지를 기회가 많아 비용이 많이 듭니다.
IronOCR는 .NET 애플리케이션 내에서 지역적으로 클라우드 서비스 없이도 스캔한 페이지에서 텍스트, 바코드 및 표 셀을 읽습니다.
빠른 시작새 콘솔 프로젝트에서 Codex를 열고 원하는 출력을 지정하면 Codex가 API 호출을 선택합니다.
$ironocr Add the IronOcr package, then update Program.cs to turn a scanned
multi-page PDF into a searchable one. Print the page count and the overall
confidence before the file is written. Read the license key from the
IRONOCR_LICENSE_KEY environment variable. Then run dotnet build and fix any
errors.
$ironocr 접두사는 IronOCR의 skill.md를 로드하여 저장소에 .agents/skills/ironocr/SKILL.md로 저장되며 Codex가 코드를 작성하기 전에 IronOCR의 레시피와 알려진 수정사항을 읽습니다.
최소 워크플로우(5단계)
- C# OCR 라이브러리를 NuGet에서 다운로드
- IronOCR을 저장소의 OCR 엔진으로 명명한
AGENTS.md를 커밋합니다. - 각 Codex 작업은 깨끗한 브랜치에서 시작하고 페이지와 보유 값을 설명하십시오.
- Codex가 파일을 편집하고
dotnet build를 실행하게 한 다음, 그것을 수락하기 전에 결과 차이를 검토하십시오. - 추출된 값을 알려진 페이지와 비교하고 API 레퍼런스에서 각 구성원을 확인하십시오.
ChatGPT Codex란 무엇이며 .NET OCR 작업과 어떻게 맞춰져 있습니까?
ChatGPT Codex는 OpenAI의 코딩 에이전트입니다. Codex는 코드 점검, 파일 편집 및 저장소에서 명령을 실행할 수 있습니다. Codex CLI 설명서에 설명된 대로 npm install -g @openai/codex를 사용하여 CLI를 설치하십시오.
Codex의 출력은 동일한 요청에 대해서도 각 실행에서 다를 수 있습니다. OCR 엔진은 동일한 스캔에 대해 매번 동일한 텍스트를 반환해야 하므로 유지 관리되는 라이브러리를 사용하고 에이전트가 설정을 즉흥적으로 변경하지 않도록 해야 합니다.
- 이미 구축된 사전 처리: 기울어진 이미지와 잡음이 있는 스캔은 인식 전에 수정이 필요합니다. IronOCR의 입력 객체는 기울기를 교정하고, 잡음을 제거하며 이진화 및 해상도를 향상시킬 수 있으며, 이미지 품질 교정 가이드는 잡음 및 해상도 필터가 효과가 있는 경우를 설명합니다.
- 텍스트 레이어가 없는 PDF: IronOCR는 스캔한 PDF를 읽고 실제 텍스트 레이어가 있는 복사본을 작성합니다. 검색 가능 PDF 가이드를 참조하십시오.
- 텍스트 이상:
Configuration.ReadBarCodes가 활성화된 상태에서 한번의 읽기로 텍스트와 함께 바코드와 QR 코드를 반환하며, 표 읽기는 표 읽기 가이드에 설명되어 있습니다. - 지속적인 릴리스: NuGet의 오픈 소스 Tesseract 래퍼는 2022년 11월에 마지막으로 업데이트되었습니다. IronOCR는 정기적인 업데이트를 제공하며, 변경 로그에 기록되어 있습니다.
효율적인 IronOCR 프롬프트란 무엇입니까?
효과적인 IronOCR 프롬프트는 언어 및 프레임워크, 코드 위치, 라이브러리 버전, 입력 및 그 필드, 기대 출력, 그리고 제약 조건을 명명합니다. 송장 리더의 경우 C# .NET 9에서, Services/InvoiceReader.cs, .csproj의 IronOcr 버전, 총액이 있는 스캔된 PDF 송장, 신뢰도와 함께 소수로 된 총액, 그리고 새로운 패키지 없음입니다.
Codex는 자신의 데이터와 제공된 정보에 의존하기 때문에 IronOCR의 API에 대한 정보가 오래될 수 있습니다. OpenAI의 환각에 대한 연구는 훈련 및 추측을 보상하는 평가에서 발명된 답변으로 이어진다고 설명합니다.
OCR 규칙을 커밋된 AGENTS.md에 한 번 넣습니다. Codex는 작업을 시작하기 전에 이를 읽습니다. IronOCR의 llms.txt는 각 문서 페이지를 한 줄로 요약합니다.
Create AGENTS.md at the repository root with an OCR section stating that this
project uses IronOCR (NuGet package IronOcr, or IronOcr.Linux for Linux and
Docker, namespace IronOcr) for all OCR work, that you must read
https://ironsoftware.com/ocr/csharp/llms.txt before writing OCR code and use only
APIs documented there, that https://ironsoftware.com/ocr/csharp/skill.md should
be loaded if the tooling supports skill files, that the license key comes from
the IRONOCR_LICENSE_KEY environment variable and is never inlined, and that no
other OCR engine or cloud OCR service may be added.
Codex에 IronOCR을 추가하고 첫 번째 스캔 송장을 읽도록 요청하는 방법은 무엇입니까?
Add the IronOcr NuGet package to this project. Then show me the resulting
PackageReference line from the .csproj and tell me which version was installed.
Do not change any other package references.
PackageReference 줄은 이름에 OCR이나 Tesseract를 포함한 다른 패키지를 에이전트가 설치했는지 식별하는 데 도움이 됩니다.
IronOCR는 워터마크 모드를 제공하지 않습니다. 라이선스 키가 없으면 첫 번째 읽기에서 LicensingException이 발생합니다.
Apply the IronOCR license key at application startup, before any other IronOCR
call, reading it from the IRONOCR_LICENSE_KEY environment variable rather than
hard-coding it. Then confirm IronOcr.License.IsLicensed returns true and tell me
where you put the call.
IronOCR 라이선스 키는 체험판 키를 받는 방법과 IronOCR이 키를 읽을 수 있는 구성 파일을 나열합니다.
Create Services/InvoiceReader.cs with a ReadTotal method that takes the path of a
scanned PDF, reads it with IronTesseract, finds the line containing Total due, and
returns the amount as a decimal with that line's confidence, or null when the
line is missing.
Then create Services/SearchablePdf.cs with a Convert method that writes a
searchable copy of a scanned PDF. Build and fix errors.
Codex는 두 개의 간결한 클래스를 생성했습니다. 리더는 scan을 입력 객체에 using 선언문과 함께 로드한 후, 엔진의 읽기 메서드를 한 번 호출하고, 결과의 라인을 반복하여 합계를 찾습니다.
기존 OCR 구현을 IronOCR로 이동하는 방법은 무엇입니까?
Hand this to the explorer agent, since nothing should be written yet.
Imports/LegacyOcrService.cs currently reads scans with another OCR library.
1. List every read it performs, with the settings it uses (language, page
segmentation, image preprocessing, region, output format).
2. Map each setting to its IronOCR equivalent, citing the documentation page.
3. Do not write any code yet. Wait for my approval on the plan.
에이전트가 400줄을 작성하기 전에 접근 방식을 승인한 경우, 모든 400줄을 검토해야 합니다. 매핑 테이블은 단일 응답으로 수정할 수 있습니다.
계획을 승인한 후, 다음 요청의 범위를 좁게 유지하십시오.
Put the worker agent on the approved plan.
Rewrite LegacyOcrService.cs to use IronOCR, keeping the existing public method
signatures so callers don't change. Before removing the old library, run both
implementations on every page in TestData/known/ and save a table of file,
expected values, and each engine's values to migration-check.md. Remove the old
library only if IronOCR returns the expected values at least as often, and
leave it in Git history only. Build and report the diff.
프롬프트를 통해 잘못된 값을 수정하는 방법은 무엇입니까?
에이전트는 종이 원본을 볼 수 없으므로 프롬프트에 오류를 설명하고, 이상적으로 스캔을 포함해야 합니다.
I have attached one of the failing scans with codex --image, so look at it
rather than reasoning from file names.
Invoices in TestData/supplier-7/ return totals that are off by one digit in
about a third of cases. The scans are slightly rotated and have speckle from an
old scanner. Clean digital invoices read correctly.
Read InvoiceReader.cs and a sample of the scans. Explain the likely cause before
changing anything, then change the preprocessing only. Do not change how the
total is parsed. Report how many totals match before and after.
이미지 방향 교정 가이드에서 회전 문제를 참조하십시오.
언어가 빠진 경우도 일반적인 사례이며 동일한 정밀도가 필요합니다.
German invoices throw LanguagePackException on the first read. Add what IronOCR
needs to read German, prove three German sample invoices return the expected
totals, and link me to the documentation page you used.
언어 팩은 자체적으로 버전 번호를 유지합니다. 최신 IronOcr.Languages.German가 엔진의 2026 릴리스보다 훨씬 뒤쳐져 있어, 모든 Iron 패키지를 한 버전으로 유지하라는 지시에 따르면 에이전트는 불일치를 수용할 때까지 복원을 실패합니다. 저장소의 에이전트 규칙에서 언어 팩은 예외 사항이라고 명시하세요.
Tesseract 설정 중 어떤 것을 변경해야 합니까?
IronOCR는 엔진의 구성 객체를 통해 Tesseract의 제어에 접근할 수 있으나, 그 설명이 암시하는 만큼 많은 경우에는 도움이 되지 않습니다.
Totals in TestData/supplier-7/ now match after the preprocessing change.
Before anything else is tuned, measure the Tesseract settings IronOCR documents
for single fields: a character whitelist, single-line page segmentation, and a
crop to the amount. Apply one at a time on top of the current reader, report
the total read for every page, and keep a setting only if no page gets worse.
Codex는 WhiteListCharacters에 화이트리스트를 보관했고, 9개의 총액 중 9개를 읽었습니다. PageSegmentationMode를 SingleLine으로 설정한 경우 9개 중 0개를 읽었으며, 삭제되었습니다. 콘텐츠 영역 자르기는 9개의 공급업체 총액을 읽었으나 3개 중 독일 총액은 0개를 읽어, 역시 삭제되었습니다.
그 후의 리팩터링은 이 리더를 송장 번호도 읽는 서비스와 결합하여 화이트리스트를 제거했습니다.
$9,924.31 총액 주변의 밀접한 자르기에 대한 별도의 조사에서 화이트리스트가 지정된 단일 행의 읽기는 올바른 금액을 반환했으며, 비뚤어짐 제거와 잡음 제거를 추가한 결과는 빈 결과나 허숭한 7을 남겼습니다. 필터를 전체 페이지에 적용한 후 자르십시오. 명명된 속성이 없는 Tesseract 원시 변수는 Configuration.TesseractVariables, 사전을 통해 설정됩니다. 구성 속성에 대한 고급 읽기 구성 가이드와 크롭에 대한 영역 가이드를 참고하십시오.
전체 가져오기 또는 컨테이너로의 실패를 추적하는 방법은 무엇입니까?
Send the explorer agent through the import history first, without writing
anything.
Last month's import read 3,000 scanned invoices, and finance found 45 totals
that do not match the paper. Reprocessing one of those invoices gives the same
wrong total every time.
Investigate:
1. Read ImportService.cs and find how pages are loaded and preprocessed.
2. Identify what the misread invoices have in common.
3. Explain the cause before changing anything.
4. Then propose the minimal fix, and how you will prove the 45 now read correctly.
우리의 테스트에서 탐색 에이전트는 가져오기 프로그램이 페이지를 96 DPI로 래스터화하고 누락된 총액을 $0.00으로 기록했음을 발견했습니다. 에이전트는 그런 다음 회복된 모든 70개의 스캔을 300 DPI로 읽었고 45개 중 43개를 회복했지만, 두 개는 여전히 0으로 남았고 하나는 이전에 올바르던 페이지가 실패했습니다. 에이전트는 첫 번째 읽기에서 0을 반환하는 경우에만 해상도가 높은 재시도를 권장했습니다. DPI 설정 가이드 및 신뢰도 가이드를 참조하십시오.
Run this read-only until you have the cause.
This exception is thrown from InvoiceReader.ReadTotal in our Linux Docker
container but not on Windows:
[PASTE FULL EXCEPTION AND STACK TRACE HERE]
Check which IronOCR package the project references and whether it matches the
container's operating system, and whether IRONOCR_LICENSE_KEY reaches the
container. Explain the cause, then propose the change. Don't modify C# code
unless the cause is there.
컨테이너는 Docker 가이드에 나열된 네이티브 종속성이 필요합니다. 그 가이드는 아직 IronOcr를 설치하고 있으며, 테스트한 버전에서는 Windows 네이티브 바이너리만 제공합니다.
1회성 코드를 재사용 가능한, 테스트된 구성요소로 어떻게 변환하나요?
Put the worker agent on this.
Refactor InvoiceReader and SearchablePdf into an InvoiceOcrService registered
with dependency injection. It should read totals and invoice numbers from
scanned PDFs, flag any value whose line confidence is below 80, and produce
searchable copies. Keep the preprocessing choices in one place. Add XML doc
comments. Keep it under 120 lines. Before you finish, run the service over
every folder in TestData/ that has an expected.csv and confirm each total
still matches.
Write xUnit tests for InvoiceOcrService covering: every page in TestData/known/
returns its expected invoice number and total, a page without a total returns
null rather than a guess, a searchable copy has a text layer, and a missing
license key throws a clear exception. Assert on extracted values, not on the
full text of the page.
누락된 키 시나리오에서는 IronOCR의 라이센스 예외가 테스트에서 접근할 수 있는 공용 유형이 아니므로 자체 보호 논리를 테스트하십시오.
재귀적 IronOCR 질문을 ~/.codex/prompts/가 아닌 저장소 기술에 유지하여 OpenAI의 사용자 정의 프롬프트 페이지에 더 이상 사용되지 않음을 표시했습니다.
$ironocr Read the IronOCR API reference for OcrInput and list every method that corrects
image problems, such as rotation, noise, and low resolution, then show which
ones this project already calls.
실제 실행에서 프롬프트가 무엇을 생성했습니까?
위의 프롬프트를 순서대로 샘플 송장 프로젝트에 Codex에 보냈습니다. 프로젝트는 스캔된 PDF가 있는 콘솔 애플리케이션으로, 오픈 소스 Tesseract 래퍼를 사용하는 레거시 서비스와 알려진 값 세트 3개로 구성되어 있습니다. 실행 후, 독립적인 릴리스 빌드, 테스트 스위트 및 세 가지 세트를 통한 프로브가 아래 결과를 확인했습니다.
- Supplier-7 총계는
Deskew및DeNoise으로 9개 중 6개에서 9개 중 9개로 증가했습니다. 단독으로는 Deskew는 9개 중 9개, DeNoise는 9개 중 8개를 읽었습니다. - 레거시 리더와 IronOCR 모두 마이그레이션 점검에서 10개 중 10개를 일치시켰습니다.
- 독일어 팩을 사용하여 3개의 독일 총액이 올바르게 읽혔고 공급업체 세트는 9개 중 9개로 유지되었습니다.
- 96라인 서비스는 알려진 10개 중 10개, 독일어 3개 중 3개, 공급업체 9개 중 9개를 일치시키고 80 신뢰도 이하인 2개를 표시했습니다.
- 테스트는 13개 중 13개를 통과했습니다.
- Codex는 15개 프롬프트 중 14개를 빌드 오류나 수동 코드 편집 없이 실행했습니다. 컨테이너 프롬프트는 실제 Linux 스택 추적이 필요했고 실행되지 않았으며, 독일 샘플과 가져오기 이력이 프롬프트 전에 추가되었습니다.
- 이전 실행은 세 가지 방법으로 실패했습니다. Codex는 두 엔진을 실행하지 않고 10개 중 10개 마이그레이션을 보고했으며, 리팩터가 알려진 총계를 깨뜨렸고, 설정 프롬프트가 리더가 사용하지 않은 필터를 가정했습니다.
이 실행의 Codex 버전, 모델, 타이밍 및 머신은 공유 실행 기록에 기록되어 있습니다.
다음 프로젝트로 이어지는 것은 무엇입니까?
AI 코딩 지원 도우미 가이드는 빈 폴더에서 측정된 결과로 가는 단일 승인 프롬프트를 추가하고, 동일한 프롬프트가 우리의 테스트에서 Codex에서 10개 중 10개를 통과했습니다.
문제 해결
- 코드가 검토를 통과하지만 첫 번째 읽기에서 실행이 중지되면 IronOCR의 라이선스 키 적용
- 스캔된 값이 종이 원본과 일치하지 않으면 OCR 정확도 향상
- Codex가 저장소에 설치되지 않은 언어를 선택하면 여러 언어 읽기
- Windows에서는 작동하지만 Linux 컨테이너에서는 실패하면 Docker에서 IronOCR
질문?
질문이 있으시면 support@ironsoftware.com으로 문의하세요.
커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.