메인 콘텐츠로 건너뛰기

Documentation Index

Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt

Use this file to discover all available pages before exploring further.

Visual Components는 Windows용 FRE에서 제공됩니다.
사용자 인터페이스가 있는 애플리케이션을 만들 때는 ABBYY FineReader Engine Visual Components를 사용할 수 있습니다. Visual Components는 OCR 애플리케이션용 사용자 인터페이스를 직접 구성할 수 있도록, 바로 사용할 수 있는 블록을 제공합니다. 처리 중인 문서를 애플리케이션 사용자에게 표시하고, 사용자가 인식 결과를 검증하고 인식된 텍스트를 편집할 수 있도록 할 수 있습니다. Visual Components는 모든 처리 시나리오에서 유용하게 활용할 수 있습니다. 예를 들어, 텍스트 편집은 Document Conversion 시나리오에서 제공할 수 있으며, 검증은 Field-Level Recognition 시나리오에서 특히 유용합니다. 이제 간단한 OCR 애플리케이션을 사용자 인터페이스 관점에서 살펴보겠습니다. 문서는 여러 처리 단계를 거칩니다.
  1. 이미지 열기
열린 이미지를 사용자에게 표시하고, 사용자가 처리 중인 문서의 페이지 사이를 이동할 수 있도록 할 수 있습니다.
  1. 인식
문서에서 텍스트 데이터를 추출하려면 문서를 인식해야 합니다. 인식된 텍스트를 사용자에게 표시하고, 사용자가 텍스트를 편집할 수 있도록 할 수 있습니다.
  1. 검증
인식된 텍스트는 검증이 필요할 수 있습니다. 사용자가 서로 비교할 수 있도록 원본 이미지와 인식된 텍스트를 모두 표시할 수 있습니다.
  1. 내보내기
인식된 문서는 적절한 저장 형식으로 저장하거나 외부 애플리케이션에서 열 수 있습니다. 아래에서는 ABBYY FineReader Engine Visual Components를 사용하는 방법을 자세히 설명합니다.
Visual Components를 사용하려면 Microsoft Windows Common Controls 버전 6.0 이상이 필요합니다.
Visual Studio에서는 ActiveX 컨트롤을 대화 상자에 삽입할 수 있습니다. Toolbox 창에 Visual Components를 추가한 다음(View 메뉴에서 Toolbox를 열 수 있음) 이를 사용할 수 있습니다.
  1. Tools 메뉴에서 Choose Toolbox Items(또는 Add/Remove Toolbox Items)를 클릭합니다.
  2. 열리는 대화 상자에서 COM Components 탭을 클릭한 다음 ABBYY DocumentViewer, ABBYY ImageViewer, ABBYY ZoomViewer, ABBYY TextEditor 및 ABBYY TextValidator 구성 요소를 선택합니다.
  3. OK를 클릭합니다. 이제 선택한 항목의 아이콘을 Toolbox에서 사용할 수 있습니다. 각 Visual Component 아이콘을 디자인 보기 화면으로 끌어다 놓을 수 있습니다. 그러면 활성 프로젝트 파일에 Visual Component 인스턴스를 생성하는 기본 코드도 함께 추가됩니다.
  4. 폼에 Visual Component를 추가한 후에는 Visual Studio에서 사용할 수 있는 해당 속성을 지정할 수 있습니다. 예를 들어, 각 구성 요소의 SettingsPath 속성은 디자인 시점에 지정해야 합니다.
Visual Studio 디자이너는 64비트 ActiveX 컨트롤을 지원하지 않습니다. 따라서 64비트 Visual Components를 Windows Form 애플리케이션에 추가할 수 없습니다. 이는 알려진 동작이며, 유사한 문제는 Microsoft ActiveX 컨트롤의 경우에도 설명되어 있습니다. 예를 들어 http://support.microsoft.com/kb/980533/en-us를 참조하세요. 이 문제를 우회할 수 있도록 FineReader Engine은 64비트 시스템에서 developer installation용 Visual Components를 선택하면 32비트와 64비트 Visual Components를 모두 설치합니다. 이 경우 Visual Studio 디자이너에서는 32비트 버전의 구성 요소로 작업할 수 있습니다. Visual Components를 사용하는 64비트 애플리케이션에는 32비트 Visual Components를 설치할 필요가 없습니다.
Component Synchronizer 구성 요소를 사용하면 애플리케이션에서 Visual Components를 동기화할 수 있습니다. 즉, 연결된 모든 구성 요소에서 보기 및 편집 작업이 모두 동기적으로 처리됩니다. Visual Components를 동기화하려면 다음과 같이 하세요.
  1. 폼이 로드될 때 새 ComponentSynchronizer 객체를 생성합니다.
  2. ComponentSynchronizer 객체의 DocumentViewer, ImageViewer, ZoomViewer, TextEditor, TextValidator 속성을 사용해 구성 요소를 Component Synchronizer에 연결합니다.
구성 요소가 API를 통해 Component Synchronizer에 연결되면 Component Synchronizer는 How Component Synchronizer Works에 설명된 대로 작동합니다.

C#

private void VisualComponentsForm_Load(object sender, System.EventArgs e)
{
 // 구성 요소를 Synchronizer에 연결
 Synchronizer = new FineReaderVisualComponents.ComponentSynchronizerClass();
 Synchronizer.DocumentViewer = ( FineReaderVisualComponents.DocumentViewer ) documentViewer.GetOcx();
 Synchronizer.ImageViewer = ( FineReaderVisualComponents.ImageViewer ) imageViewer.GetOcx();
 Synchronizer.ZoomViewer = ( FineReaderVisualComponents.ZoomViewer ) zoomViewer.GetOcx();
 Synchronizer.TextEditor = ( FineReaderVisualComponents.TextEditor ) textEditor.GetOcx();
}
ABBYY FineReader Engine을 사용하려면 Engine 객체를 생성해야 합니다. Engine 객체를 생성하려면 내보낸 함수 InitializeEngine을 사용할 수 있습니다. 엔진 객체를 로드하는 다른 방법도 참조하세요. 이미지 로드 중이나 폼 초기화 시점에 엔진 객체를 로드할 수 있습니다.

C#

[DllImport( "FREngine.dll", CharSet=CharSet.Unicode ), PreserveSig]
private static extern int InitializeEngine(
 String customerProjectID,
 String licensePath,
 String licensePassword,
 String FREngineDataFolder,
 String FREngineTempFolder,
 Bool lsSharedCPUCoresMode,
 ref FREngine.IEngine engine );
private void loadEngine()
{
 int hresult = InitializeEngine( "<CustomerProjectID>",
 "<licensePath>",
 "<licensePassword>",
 "<FREngineDataFolder>",
 "<FREngineTempFolder>",
 false,
 ref Engine );
 Marshal.ThrowExceptionForHR( hresult );
}
Visual Components에 이미지를 표시하려면 이미지를 열어야 합니다. 이미지 열기는 다음 절차로 구현할 수 있습니다.
  1. 단일 문서의 이미지를 로드하려면 FRDocument 객체를 생성하고 여기에 이미지를 추가해야 합니다. 다음 방법 중 하나를 사용할 수 있습니다.
  2. ComponentSynchronizer 객체의 Document 속성을 사용해 문서를 Component Synchronizer에 연결합니다.
이 절차는 이미지를 여는 버튼의 “on click” 이벤트 처리기로 사용할 수 있습니다.

C#

private void openImage( string imageFileName )
{
 // ABBYY FineReader Engine 로드
 if( Engine == null )
 {
  loadEngine();
  Engine.ParentWindow = this.Handle.ToInt32();
  Engine.ApplicationTitle = this.Text;
 }
 // 이미지 열기
 Document = Engine.CreateFRDocumentFromImage( imageFileName, null );
 // Synchronizer를 사용하여 이미지를 Visual Components에 연결
 Synchronizer.Document = Document;
}
Visual Components에서 이미지 인식은 구성 요소에서 사용할 수 있는 명령을 사용하거나 FineReader Engine API(예: FRDocument 객체의 Process 메서드)를 사용하여 수행할 수 있습니다.인식을 위해 다음 절차를 구현할 수 있습니다.
  1. FRDocument 객체의 메서드를 사용하여 문서를 인식합니다.
  2. 문서가 Visual Components GUI를 통해 변경된 것이 아니므로 변경 사항을 Visual Components에 알려야 합니다. 문서의 각 페이지에 대해 FRPage 객체의 Update 메서드를 사용합니다.
이 절차는 인식을 호출하는 버튼의 “on click” 이벤트를 처리할 수 있습니다.

C#

private void recognizeDocument()
{
 // 전체 문서를 인식하고 합성합니다
 Document.Process( Synchronizer.ProcessingParams );
 // 변경 사항을 Visual Components에 알립니다
 for( int i = 0; i < Document.Pages.Count; i++ )
 {
  Document.Pages[i].Update();
 }
}
인식된 데이터는 Text Validator 구성 요소를 사용하여 검증할 수 있습니다. 이 구성 요소는 문자가 올바르게 인식되었는지 확인하고, 필요하면 수정할 수 있는 사용자 인터페이스를 제공합니다.검증을 위해 다음 절차를 구현할 수 있습니다.
  1. 현재 폼에 Text Validator 구성 요소를 추가하거나 이를 위한 새 폼을 만듭니다.
  2. Text Validator 구성 요소를 Component Synchronizer에 연결합니다. ComponentSynchronizer 객체의 TextValidator 속성을 사용합니다.
  3. TextValidator 객체의 Spell 메서드를 사용하여 검증 프로세스를 시작합니다.

C#

private void validateButton_Click(object sender, System.EventArgs e)
{
 if( validatorForm == null )
 {
  // 검증을 위한 새 폼 생성
  validatorForm = new ValidatorForm();
  validatorForm.Owner = this;
  // validator를 synchronizer에 연결
  Synchronizer.TextValidator = ( FineReaderVisualComponents.TextValidator ) validatorForm.TextValidator.GetOcx();
  validatorForm.Show();
  // 연결된 문서의 인식된 텍스트를 검증
  validatorForm.TextValidator.Spell( null );
 }
}
인식된 문서는 Document Viewer에서 사용할 수 있는 명령이나 FineReader Engine API를 사용하여 저장할 수 있습니다.예를 들어, FRDocument 객체의 Export 메서드를 사용하고 FileExportFormatEnum 상수를 매개변수 중 하나로 지정합니다. FRDocument 객체 작업을 마친 후에는 이 객체가 사용한 모든 리소스를 해제해야 합니다. IFRDocument::Close 메서드를 사용합니다. 이 절차는 내보내기를 호출하는 버튼의 “on click” 이벤트를 처리할 수 있습니다.

C#

// 인식된 문서를 RTF로 저장
Document.Export( "<File name>", FREngine.FileExportFormatEnum.FEF_RTF, null );
// FRDocument 객체 해제
Document.Close();
ABBYY FineReader Engine 작업을 마친 후에는 Engine 객체를 언로드해야 합니다. 이를 위해 DeinitializeEngine 내보낸 함수를 사용합니다.
Engine deinitialization 전에 Component Synchronizer를 해제하는 것이 좋습니다.
이 절차는 애플리케이션 창을 닫는 버튼의 “on click” 이벤트를 처리할 수 있습니다.

C#

[DllImport( "FREngine.dll", CharSet=CharSet.Unicode ), PreserveSig]
private static extern int DeinitializeEngine();
private void unloadEngine()
{
 if( Engine != null )
 {// Engine이 로드된 경우 언로드
  Engine = null;
  int hresult = DeinitializeEngine();
  Marshal.ThrowExceptionForHR( hresult );
 }
}
설명된 절차의 샘플 구현은 VisualComponents sample에서 확인할 수 있습니다.

참고 항목

Visual Component의 컨텍스트 메뉴와 도구 모음 사용자 지정