Main Page | Modules | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages | Search

vvxtrSample.cc File Reference

Sample file for the OCR Shop XTR/API. More...

#include <vvocr/vvxtrFactory.h>
#include <string>
#include <ios>
#include <iostream>
#include <fstream>
#include <signal.h>

Include dependency graph for vvxtrSample.cc:

Include dependency graph

Go to the source code of this file.

Functions

vvEngAPICreateEngine ()
 Function to create an OCR engine.

vvxtrStatus runOCR (vvEngAPI *xtrEngine)
 Basic image processing example.

vvxtrStatus processOneDocument (vvEngAPI *xtrEngine)
 Process one input document, which may have multiple pages.

vvxtrStatus openImageDocument (vvEngAPI *xtrEngine, char *inputFilename)
 Open an input image file.

vvxtrStatus processOnePage (vvEngAPI *xtrEngine)
 Process one page.

vvxtrStatus outputDoc (vvEngAPI *xtrEngine)
 Output a document of OCR results (PDF, ASCII, unicode, or XDOC).

vvxtrStatus outputImg (vvEngAPI *xtrEngine)
 Capture a subimage from the original input image, and obtain the output image through memory or in a file.

void CloseDown ()
 Call this function on exit.

void SigTermHandler (int param)
 SigTerm handler.

void SigErrorHandler (int param)
 SigError handler.

int main (int argc, char **argv)

Variables

string g_remoteEngine
vvEngAPIg_xtrEngine = NULL


Detailed Description

Sample file for the OCR Shop XTR/API.

This sample program demonstrates basic functionality of the OCR Shop XTR/API, including reading image data from a file, setting preprocessing and recognition options, and generating text and subimage output.

Copyright (C) 2003, Vividata, All Rights Reserved

Definition in file vvxtrSample.cc.


Function Documentation

vvEngAPI * CreateEngine  ) 
 

Function to create an OCR engine.

This function allocates space for the new engine, which this program is subsequently responsible for deleting.

This is the only way to create an OCR engine: you will need to call the vvxtrCreateRemoteEngine function.

Returns:
A pointer to a new OCR engine (vvEngAPI)

Definition at line 176 of file vvxtrSample.cc.

References vvxtrCreateRemoteEngine().

vvxtrStatus openImageDocument vvEngAPI xtrEngine,
char *  inputFilename
 

Open an input image file.

Parameters:
xtrEngine OCR engine pointer
inputFilename Name of TIFF file to open.
Returns:
vvxtrStatus

Definition at line 348 of file vvxtrSample.cc.

References dm_in_filename, vvEngAPI::vvOpenImageFile(), vvEngAPI::vvSetValue(), VVXTR_ERR, VVXTR_ERR_UNABLE_TO_LOAD_IMAGE_FILE, and vvxtrStatus.

Referenced by processOneDocument().

vvxtrStatus outputDoc vvEngAPI xtrEngine  ) 
 

Output a document of OCR results (PDF, ASCII, unicode, or XDOC).

Parameters:
xtrEngine A pointer to the engine currently used in this sample program.
Returns:
vvxtrStatus

Definition at line 594 of file vvxtrSample.cc.

References dm_doc_memory_size, outputDoc(), vvEngAPI::vvAcquireDocFile(), vvEngAPI::vvAcquireDocMemory(), vvEngAPI::vvEndDoc(), vvEngAPI::vvGetValue(), vvEngAPI::vvSpoolDoc(), vvEngAPI::vvStartDoc(), vvTextFormatIso, vvTextFormatPdf, vvTextFormatUnicode, vvTextFormatXdoc, VVXTR_ERR, and vvxtrStatus.

Referenced by outputDoc(), and processOnePage().

vvxtrStatus outputImg vvEngAPI xtrEngine  ) 
 

Capture a subimage from the original input image, and obtain the output image through memory or in a file.

Parameters:
xtrEngine A pointer to the engine currently used in this sample program.
Returns:
vvxtrStatus

Definition at line 433 of file vvxtrSample.cc.

References dm_focus_area, dm_out_graphics_format, dm_region_ids, dm_region_ids_image, dm_region_ids_text, dm_subimage_memory_size, vvxtrImage::FromRaw(), outputImg(), vvEngAPI::vvAcquireSubimageFile(), vvEngAPI::vvAcquireSubimageMemory(), vvEngAPI::vvCaptureSubimage(), vvFocusAreaPage, vvFocusAreaRegion, vvEngAPI::vvGetValue(), vvEngAPI::vvSetValue(), vvSubimageFormatEPdf, vvSubimageFormatGif, vvSubimageFormatJpeg, vvSubimageFormatPng, vvSubimageFormatRgb, vvSubimageFormatTiffpack, vvSubimageFormatVvxtrImage, VVXTR_ERR, and vvxtrStatus.

Referenced by outputImg(), and processOnePage().

vvxtrStatus processOneDocument vvEngAPI xtrEngine  ) 
 

Process one input document, which may have multiple pages.

This function encompasses reading in the file, pre-processing, recognition, and document as well as subimage output.

Parameters:
xtrEngine OCR engine pointer
Returns:
vvxtrStatus

Definition at line 268 of file vvxtrSample.cc.

References dm_in_curr_page, dm_in_num_pages, openImageDocument(), processOneDocument(), processOnePage(), vvEngAPI::vvCloseImageFile(), vvEngAPI::vvGetValue(), vvEngAPI::vvReadImageData(), vvEngAPI::vvSetValue(), vvEngAPI::vvUnloadImage(), VVXTR_ERR_INVALID_PAGE, and vvxtrStatus.

Referenced by processOneDocument(), and runOCR().

vvxtrStatus processOnePage vvEngAPI xtrEngine  ) 
 

Process one page.

This function preprocesses and recognizes one page of image data. It then presents the user with the option of generating output of the recognized text or creating subimages from the original image.

Output documents can cover multiple pages and multiple input documents, but for the purposes of this example, we limit output documents to one page of recognized text.

Parameters:
xtrEngine OCR engine pointer
Returns:
vvxtrStatus

Definition at line 390 of file vvxtrSample.cc.

References outputDoc(), outputImg(), processOnePage(), vvEngAPI::vvPreprocess(), vvEngAPI::vvRecognize(), VVXTR_ERR, and vvxtrStatus.

Referenced by processOneDocument(), and processOnePage().

vvxtrStatus runOCR vvEngAPI xtrEngine  ) 
 

Basic image processing example.

This routine prompts a user to submit an image file for recognition, then the user can choose to output a text or subimage results. An arbitrary number of input images may be recognized, and the user can choose which page to recognize. All OCR takes place within one OCR session (vvEngAPI::vvStartOCRSes), so for the best results, all input images recognized within one run of this program should be from the same batch or source, so that the internal training within the OCR session is productive.

Returns:
vvxtrStatus

Definition at line 196 of file vvxtrSample.cc.

References dm_format_analysis, dm_pp_auto_segment, dm_pp_segment_lineart, processOneDocument(), runOCR(), vvEngAPI::vvEndInstance(), vvEngAPI::vvEndOCRSes(), vvHintLocalFilesystem, vvEngAPI::vvInitInstance(), vvEngAPI::vvInitValues(), vvEngAPI::vvSetHint(), vvEngAPI::vvSetValue(), vvEngAPI::vvStartOCRSes(), vvxtrStatus, and vvYes.

Referenced by runOCR().


Generated on Thu Dec 11 09:32:24 2003 for OCR Shop XTR/API User Documentation by doxygen 1.3.2