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

vvxtrAPI.h

Go to the documentation of this file.
00001 
00015 #ifndef VVXTRAPI_H
00016 #define VVXTRAPI_H 1
00017 
00018 #include "vvxtrDefs.h"
00019 #include "malloc.h"
00020 #include "memory.h"
00021 
00426 class vvEngAPI 
00427 {
00428 public:
00429     vvEngAPI() { memset(m_hints,0,sizeof(m_hints)); }// No hints to begin with! 
00430 
00434     virtual ~vvEngAPI() {};
00435 
00445     virtual vvxtrStatus vvKill() = 0;
00446 
00459     virtual vvxtrStatus vvInitInstance() = 0;
00460 
00468     virtual vvxtrStatus vvEndInstance() = 0;
00469 
00517     virtual vvxtrStatus vvStartOCRSes() = 0;
00518 
00526     virtual vvxtrStatus vvEndOCRSes() = 0;
00527 
00551     virtual vvxtrStatus vvStartDoc() = 0;
00552 
00561     vvxtrStatus vvStartDoc(int fileFormat)
00562     {
00563         vvERROR(vvSetValue(dm_out_text_format, (vvxtr_stdarg)fileFormat));
00564 
00565         return vvStartDoc();
00566     }
00567 
00592     virtual vvxtrStatus vvSpoolDoc() = 0;
00593 
00616     virtual vvxtrStatus vvEndDoc() = 0;
00617 
00640     virtual vvxtrStatus vvAcquireDocMemory(void * memPtr,int bufsize) = 0;
00641 
00658     virtual vvxtrStatus vvAcquireDocFile(const char * filename) = 0;
00659 
00674     virtual vvxtrStatus vvCaptureSubimage() = 0;
00675 
00685     vvxtrStatus vvCaptureSubimage( int regionID )
00686     {
00687         vvERROR(vvSetValue(dm_current_region, (vvxtr_stdarg)regionID));
00688         return vvCaptureSubimage();
00689     }
00690 
00711     virtual vvxtrStatus vvAcquireSubimageMemory(void * memPtr,int bufsize) = 0;
00712 
00727     virtual vvxtrStatus vvAcquireSubimageFile(const char * filename) = 0;
00728 
00745     virtual vvxtrStatus vvOpenImageFile() = 0;
00746 
00759     vvxtrStatus vvOpenImageFile( const char * fileName )
00760     {
00761         vvERROR(vvSetValue(dm_in_filename,(vvxtr_stdarg)fileName));
00762         return vvOpenImageFile();
00763     }
00764 
00786     virtual vvxtrStatus vvCloseImageFile() = 0;
00787 
00801     virtual vvxtrStatus vvReadImageData() = 0;
00802 
00829     virtual vvxtrStatus vvReadImageData(const struct vvxtrImage * img) = 0;
00830 
00849     virtual vvxtrStatus vvUnloadImage() = 0;
00850 
00876     virtual vvxtrStatus vvPreprocess() = 0;
00877 
00898     virtual vvxtrStatus vvRecognize() = 0;
00899 
00905     virtual vvxtrStatus vvInitValues() = 0;
00906 
00915     virtual vvxtrStatus vvGetStatus(const int key, vvxtr_stdarg *result) = 0;
00916 
00917 #ifndef DOXYGEN
00918     virtual vvxtrStatus vvSetValue(const int key, const vvxtr_stdarg value) = 0;
00919 #endif
00920 
00929     vvxtrStatus vvSetValue( const int key, int value)
00930     {
00931         return vvSetValue( key, (vvxtr_stdarg)value);
00932     }
00942     vvxtrStatus vvSetValue( const int key, char * value )
00943     {
00944         return vvSetValue( key, (vvxtr_stdarg)value);
00945     }
00946 
00947 #ifndef DOXYGEN
00948     virtual vvxtrStatus vvGetValue(const int key, vvxtr_stdarg *result, VVXTR_DATATYPE *resultType) = 0;
00949 #endif
00950 
00959     vvxtrStatus vvGetValue( const int key, int * result )
00960     {
00961         return vvGetValue( key, (vvxtr_stdarg*)result, NULL);
00962     }
00972     vvxtrStatus vvGetValue( const int key, char ** result )
00973     {
00974         return vvGetValue( key, (vvxtr_stdarg*)result, NULL);
00975     }
00976 
00977 
00990     virtual vvxtrStatus vvGetState(vvxtr_state *resultState) = 0;
00991 
01005     virtual vvxtrStatus vvGetCond(const vvxtr_cond c, int *result) = 0;
01006     
01018     virtual vvxtrStatus vvSetHint(vvxtrHint hint, bool set=true) {  m_hints[hint]=set ; return VV_OK ; }
01019 
01027     virtual bool vvGetHint(vvxtrHint hint) { return m_hints[hint]; }
01028 
01037     virtual void vvSigHUP() { }
01038 
01048     virtual const char * vvGetStatusString(vvxtrStatus status= VVXTR_PREVIOUS_ERROR)
01049     {
01050         if (status==VVXTR_PREVIOUS_ERROR)
01051         {
01052             return "No information";
01053         }
01054 
01055         switch (status)
01056         {
01057             case VVXTR_ERR_INVALID_SYNTAX:              return "Invalid syntax";
01058             case VVXTR_ERR_NO_INPUT:                    return "No input";
01059             case VVXTR_ERR_INVALID_STATE:               return "Invalid state";
01060             case VVXTR_ERR_INITINSTANCE_FAILURE:        return "Initialization of instance failed";
01061             case VVXTR_ERR_ENDINSTANCE_FAILURE:         return "Ending instance failed";
01062             case VVXTR_ERR_NO_INPUT_FILE_SPECIFIED:     return "No input file was specified";
01063             case VVXTR_ERR_UNABLE_TO_LOAD_IMAGE_FILE:   return "Unable to load image data from the file";
01064             case VVXTR_ERR_IMG_ACQ_FAILED:              return "Image upload to OCR kernel failed";
01065             case VVXTR_ERR_START_SESSION_FAILED:        return "Starting OCR session failed";
01066             case VVXTR_ERR_RECOGNITION_FAILED:          return "Recognition failed";
01067             case VVXTR_ERR_OPEN_CHAR_SET_FAILURE:       return "Unable to open character set";
01068             case VVXTR_ERR_INVALID_SHAPE_PACK_PATH:     return "Invalid shape pack path";
01069             case VVXTR_ERR_BAD_LANGUAGE:                return "Bad language pack";
01070             case VVXTR_ERR_OPENING_LANG_PACK:           return "Unable to open language pack";
01071             case VVXTR_ERR_LOAD_LANG_FAILED:            return "Unable to load language";
01072             case VVXTR_ERR_CREATE_LANG_GROUP:           return "Unable to create a language group";
01073             case VVXTR_ERR_SET_DEF_LEX_CONSTRAINTS:     return "Unable to set default lexical constraints";
01074             case VVXTR_ERR_WRITE_OUTPUT_FAILED:         return "Unable to write output";
01075             case VVXTR_ERR_OPENING_OUTPUT_FILE:         return "Unable to open output file";
01076             case VVXTR_ERR_REGION_ECLIPSED:             return "Region eclipsed";
01077             case VVXTR_ERR_COULD_NOT_CONVERT_DEPTH:     return "Unable to convert image depth";
01078             case VVXTR_ERR_GETTING_IMG_REGION:          return "Unable to get image region";
01079             case VVXTR_ERR_END_SESSION_FAILED:          return "Unable to end session";
01080             case VVXTR_ERR_OUTPUT_INV_REGION:           return "Error in output of inv region";
01081             case VVXTR_ERR_NOT_IMPLEMENTED:             return "Feature not implemented";
01082             case VVXTR_ERR_INV_PDF_FORMAT:              return "Invalid PDF format";
01083             case VVXTR_ERR_PDF_IMG_OUTPUT:              return "Error in PDF image output";
01084             case VVXTR_ERR_PDF_END_OUTPUT:              return "Error in finishing PDF output";
01085             case VVXTR_ERR_HOST_LOOKUP_FAILED:          return "The remote name lookup failed";
01086             case VVXTR_ERR_CONNECTION_FAILED:           return "The remote connection  failed";
01087             case VVXTR_ERR_NO_SUBIMAGE:                 return "No subimage available to acquire.";
01088             case VVXTR_ERR_PP_FAILED:                   return "Preprocessing failed.";
01089             case VVXTR_ERR_SET_OPTIONS_FAILED:          return "Set options failed.";
01090             case VVXTR_ERR_REMOVE_FILE_FAILED:          return "Removal of temp file failed.";
01091             case VVXTR_ERR_NO_DOC:                      return "No doc available to acquire.";
01092             case VVXTR_ERR_INV_SUBIMG_FORMAT:           return "Invalid subimage format.";
01093             case VVXTR_ERR_TRANSFER_FAILED:             return "The data transfer failed";
01094             case VVXTR_ERR_SYNCHRONIZATION:             return "The client and server are out of synch";
01095             case VVXTR_ERR_NOENGINE:                    return "The engine hasn't been allocated yet";
01096             case VVXTR_ERR_BUFFER_TOO_SMALL:            return "The buffer size is too small to receive all of the data";
01097             case VVXTR_ERR_INVALID_PAGE:                return "Invalid page in input image was specified";
01098             case VVXTR_ERR_MISSING_LANG:                return "Add user lexicon missing language";
01099             case VVXTR_ERR_ENG_OUT_OF_MEMORY:           return "Internal OCR engine is out of memory";
01100             case VVXTR_ERR_INVALID_UOR_COUNT:           return "UOR count is invalid";
01101             case VVXTR_ERR_INVALID_UOR_STRING:          return "UOR string contains an invalid character";
01102             case VVXTR_ERR_READONLY_VALUE:              return "Can not write to a read-only value.";
01103             case VVXTR_ERR_INVALID_REGION_ID:           return "Invalid region id.";
01104             case VVXTR_ERR_SET_REGION_UNSUCCESSFUL:     return "Call to vvSetRegion was unsuccessful.";
01105             case VVXTR_ERR_REGION_HANDLER:              return "Kernel error in the region handler.";
01106             case VVXTR_ERR_NO_LICENSE_MANAGER:          return "License manager unavailable, and starting it was unsuccessful";
01107             case VVXTR_ERR_NO_LICENSE:                  return "No licenses are available for checkout";
01108             case VVXTR_ERR_NO_FEATURE:                  return "Feature not available.";
01109             case VVXTR_ERR_ENGINE_KILLED:               return "Engine has been killed with vvKill; no further commands are possible.";
01110             default:                                    return "Undocumented error";
01111         }                                               
01112     }
01113 
01122     virtual vvxtrStatus vvGetVersion( vvxtrVersionLocationEnum loc, const char ** ver ) = 0;
01123 
01141     virtual vvxtrStatus vvAddWordToLexicon( const char *word, int constraintId ) = 0;
01142 
01177     virtual vvxtrStatus vvSetLexicalConstraints( int mode ) = 0;
01178 
01209 /*  Currently unsupported options:
01210     * - ::dm_region_textformat (::vvxtrOutTextFormatEnum)
01211     * - ::dm_region_prefix (string for \ref region prefix)
01212     * - ::dm_region_suffix (string for \ref region suffix)
01213     * - ::dm_region_opacity (::vvxtrRegionOpacityEnum)
01214     * - ::dm_region_abutment (::vvxtrRegionAbutmentEnum)
01215     * - ::dm_region_parent (\ref region id of parent \ref region)
01216  */
01217     virtual vvxtrStatus vvSetRegionProperties( void ) = 0;
01218 
01240     virtual vvxtrStatus vvForceRegionForeground( int foregroundColor ) = 0;
01241 
01252     virtual vvxtrStatus vvRemoveRegion( void ) = 0;
01253 
01254     bool m_hints[vvNumberOfHints] ;         
01255 private:
01256 
01257 } ;
01258 
01259 
01280 class vvxtrImage 
01281 {
01282 public:
01283 
01287     vvxtrImage() { memset(this,0,sizeof(vvxtrImage)); size = sizeof(vvxtrImage) ; };
01288 
01289 
01295     void SetWidth(unsigned int width) { dwImgWidth = width; }
01301     void SetHeight(unsigned int height) { dwImgHeight = height; }
01302     
01308     void SetBytesPerLine(unsigned int bpl) { dwBytesPerLine = bpl; }
01309     
01315     void SetXDPI(unsigned short int xdpi) { wXDPI = xdpi; }
01316     
01322     void SetYDPI(unsigned short int ydpi) { wYDPI = ydpi; }
01328     void SetBitsPerPixel(unsigned short int bpp) { chBitsPerPixel = bpp; }
01336     void SetBitsPerSample(unsigned short int bps) { wBitsPerSample = bps; }
01342     void SetData(unsigned char * imgData) { data = const_cast<unsigned char *>(imgData); }
01343 
01349     unsigned int    GetWidth() { return dwImgWidth; }
01355     unsigned int    GetHeight() { return dwImgHeight; }
01361     unsigned int    GetBytesPerLine() { return dwBytesPerLine; }
01367     unsigned short int GetXDPI() { return wXDPI; }
01373     unsigned short int GetYDPI() { return wYDPI; }
01379     unsigned short int GetBitsPerPixel() { return chBitsPerPixel; }
01386     unsigned short int  GetBitsPerSample() { return wBitsPerSample; }
01387     
01393     unsigned char * GetData() { return data; }
01394     const unsigned char * GetData() const { return data; }
01395 
01401     int GetImageSize() const { return dwImgHeight*dwBytesPerLine; }
01408     int GetTotalSize() const { int thisSize = sizeof(vvxtrImage) ;return thisSize+GetImageSize(); } ; 
01409 
01424     static vvxtrImage * FromRaw( void * rawbuffer )
01425     {
01426         memset(rawbuffer,0,sizeof(vvxtrImage));
01427         vvxtrImage * newThis = (vvxtrImage*)rawbuffer;
01428 
01429         newThis->SetData( (unsigned char *)(newThis+1) );
01430         return newThis ;
01431     }
01432 
01433 protected:
01434     int     size;                           
01435     unsigned int        dwImgWidth;         
01436     unsigned int        dwImgHeight;        
01437     unsigned int        dwBytesPerLine;     
01438     unsigned short int  wXDPI;              
01439     unsigned short int  wYDPI;              
01440     unsigned short int  chBitsPerPixel;     
01441     unsigned short int  wBitsPerSample;     
01443     unsigned char * data ;                  
01445 };
01446 
01447 #endif
01448 

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