문제

내 문서를 인식하기 위해 FlexIcapture 프로세서를 사용하고 있습니다. 나는 여러 페이지의 문서가있는 문서를 가지고 있습니다. 문서에는 여러 이미지가 있고 각 이미지는 인식해야합니다.

나는 문서의 하나의 이미지, 문서의 여러 이미지 중 하나의 이미지를 달성하기 위해 아래의 절차를 다음과 같이 처리합니다.

  1. 프로세서 생성
  2. 문서 정의 파일 또는 AFL 파일 추가
  3. IDocument Document= Processor.RecognizEntDocument ()로 인식을 실행합니다. 그러나 문서를 반환하면 문서의 첫 번째 페이지 인 페이지가 하나뿐입니다. 왜 그렇게 그렇습니다.
  4. 다른 경우 프로젝트를 대신 프로젝트를 사용하는 경우 아래의 절차

    와 함께 iProject

    1. 프로젝트 만들기
    2. 프로젝트 Project.getBatches (),
    3. 에서 일괄 처리 가져 오기
    4. 배치
    5. 에 문서를 추가합니다.
    6. 를 인식합니다 Document, Idocuments 문서= Batch.GetDocuments (),
    7. 문서의 모든 페이지 정보

      어떻게 동일한 작업을 수행 할 수 있습니까? 나는 프로세서가 문서의 모든 페이지를 인식하고 모든 페이지로 문서를 반환하고 싶습니다. ?

      무언가가 불분명하다면 pls는 자세한 정보를 요청합니다. 최대한 빨리 회신 해주십시오 ... 코드 : 1 FlexiCapture 프로세서 사용 / ** ...에 * * /

      / ** * @author nitin. ...에 * * /

      import java.sql.BatchUpdateException;
      
      import com.abbyy.FCEngine.*;
      
      public class FlexicaputreVerificationUsingProcessor {
      private static Object verificationWorkSet(Object object) {
          // TODO Auto-generated method stub
          return null;
      }
      private static void trace( String txt ) 
      {
          System.out.println( txt );
      }
      
      static private String samplesFolder;
      static private String projectFolder;
      static private String serialNumber;
      static private String dllPath;
      
      static {
      
          samplesFolder = "C:\\ProgramData\\ABBYY\\SDK\\10\\FlexiCapture Engine\\Samples\\";
          projectFolder = "C:\\Users\\Nitin\\FlexicaptureTest\\flexiverificationtest" ; 
      
          try {
      
              java.io.FileInputStream file = new java.io.FileInputStream( samplesFolder + "SampleConfig\\SamplesConfig.txt" );
      
              java.io.BufferedReader reader = new java.io.BufferedReader( new java.io.InputStreamReader( file ) );
      
              serialNumber = reader.readLine();
      
              dllPath = reader.readLine();
      
              file.close();
      
          } catch( java.io.IOException e ) {
               System.out.println( e.getMessage() );
               e.printStackTrace();
          }
      }
      
      
      /**
       * @param args
       */
      public static void main(String[] args) {
      
          // Load Engine 
          try {
                  trace("Loading engine");
                  IEngineLoader engineLoader= Engine.CreateEngineOutprocLoader();
                  IEngine engine = engineLoader.Load(serialNumber,dllPath);
      
                  try {
      
                      // Create and configure FlexiCaptureProcessor
                      trace("Creating and configureing FlexiCaptureProcessor");
                      IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
                      processor.AddDocumentDefinitionFile( projectFolder + "\\Document_Definition_1.fcdot" );
      
                      trace("Adding images/pdf to processor");
                      final int fileCount = 1 ; 
      
                      processor.AddImageFile(projectFolder + "\\don't upload to big .pdf");
      
                      engine.EnableRecognitionVariants( true );
      
                      trace("Creating Document collection");
                      IDocumentsCollection documentsCollection = engine.CreateDocumentsCollection();
      
                      trace( "Reconizing Images/pdfs..." );
                      int totalErrors = 0 ; 
                      for ( int iterator = 0 ; iterator<fileCount; iterator++ ){
                          trace("Recongnizing image/pdf number: " +(iterator+1));
                          IDocument document = processor.RecognizeNextDocument(); 
      
                          trace("Getting last processing error for checksum");
                          IProcessingError lastProcessingError = processor.GetLastProcessingError() ;
      
                          if ( lastProcessingError !=null)
                          {
                              String errormsg = lastProcessingError.MessageText(); 
                              totalErrors++;
      
                              trace("Error occured while recognizeing document, Document number: "+(iterator+1)+ " with Error msg: "+errormsg);
                              //since we are not handling error (right now) so moving to next document for recognization  
                              processor.ResumeProcessing(false);
      
                          }else {
                              trace("No error occured while recognization of document number : "+(iterator+1));
                          }
                          trace("Adding documents in Documents collection");
                          documentsCollection.Add(document);
      
                      }
      
                      if ( totalErrors == fileCount){
                          trace("Facing Error for all document while recongnization");
                          return ; 
                      }
      
                      trace("Creaing Verification session");
      
                      try {
      
                          IVerificationSession verificationSession = engine.CreateVerificationSession(documentsCollection) ; 
      
                          try {
      
                              //enabling context verification
                              verificationSession.getOptions().setVerifyFields(true); 
      
                              //disabling group verification 
                              verificationSession.getOptions().setVerifyBaseSymbols(false);
                              verificationSession.getOptions().setVerifyExtraSymbols(false);
      
                              try {
                                  trace("Get NextWork Set");
                                  IVerificationWorkSet verificationWorkSet =  verificationSession.NextWorkSet();
      
                                  if ( verificationWorkSet == null){
                                      trace("first verificationWork set is null");
                                  }else {
      
                                      //process each work set in Verification session
                                      trace("Processing Work Set");
                                      while ( verificationWorkSet != null ){
      
                                          try{
                                              trace("Geting Verification group");
                                              //get next group for verification 
                                              IVerificationGroup verificationGroup = verificationWorkSet.NextGroup(); 
      
                                              if ( verificationGroup == null ){
                                                  trace("First verification group is null");
                                              }else {
                                                  trace("processing each group of a workset");
                                                  //processing each group of a work set
                                                  while ( verificationGroup!= null){
                                                      int verificationObjectInAGroupCount =  verificationGroup.getCount(); 
                                                      trace("Total number of verification object: " +verificationObjectInAGroupCount);
      
                                                      for ( int iterator = 0; iterator<verificationObjectInAGroupCount; iterator++){
                                                          trace ( "getting and Processing "+(iterator +1 ) + " verification object of A group");
      
                                                          //getting verification object 
                                                          IVerificationObject verificationObject = verificationGroup.getElement(iterator);
                                                          if ( verificationObject == null){
                                                              trace("verification object is null");
                                                          }else {
                                                              if ( verificationObject.getType() == VerificationObjectTypeEnum.VOT_Group ) {
                                                                  IGroupVerificationObject groupVerificationObject = verificationObject.AsGroupVerificationObject(); 
      
                                                                  if ( groupVerificationObject == null){
                                                                      System.out.println("group verification object is null ");
                                                                  }
      
      
                                                              }else if ( verificationObject.getType() == VerificationObjectTypeEnum.VOT_Context) {
                                                                  IContextVerificationObject  contextVerificationObject = verificationObject.AsContextVerificationObject(); 
      
      
      
      
                                                                  if ( contextVerificationObject == null){
                                                                      trace("ContextVerification object is null");
                                                                  }else {
                                                                      IField field = contextVerificationObject.getField(); 
                                                                      if ( field == null){
                                                                          trace("field getting null");
                                                                      }else {
                                                                          System.out.println(" field full name: " +field.getFullName() + "\n Name: " +field.getName());
      
                                                                          IFieldValue fieldValue = field.getValue();
                                                                          if ( fieldValue == null){
                                                                              trace("Field Value is Null");
                                                                              }else {
      
                                                                          trace ( "getting text from field value");
                                                                              IText text = fieldValue.getAsText() ; 
                                                                              if ( text == null){
                                                                                  trace("text getting null in field value");
                                                                              }else {
      
      
                                                                                  int wordCount = text.getRecognizedWordsCount() ; 
                                                                                  trace("recognized word count: "+wordCount);
      
                                                                                  //getting words from text 
                                                                                  for ( int wordIndex = 0 ; wordIndex<wordCount; wordIndex++ ){
                                                                                      trace ("processing word number :" +wordIndex);
      
                                                                                      IRecognizedWordInfo recognizedWordInfo = engine.CreateRecognizedWordInfo()  ; 
      
                                                                                      if ( recognizedWordInfo == null){
                                                                                          trace("Can't create recognizedWordInfo object using engine");
                                                                                      }else {
                                                                                          text.GetRecognizedWord(wordIndex, -1, recognizedWordInfo);
      
                                                                                          //getting characters from word
                                                                                          for (int characterIndex = 0 ; characterIndex<recognizedWordInfo.getText().length(); characterIndex++ ){
                                                                                              trace("processing character number : " +characterIndex);
      
                                                                                              IRecognizedCharacterInfo recognizedCharacterInfo = engine.CreateRecognizedCharacterInfo(); 
                                                                                              if ( recognizedCharacterInfo == null) {
                                                                                                  trace("can't create recognizedCharacterInfo object");
                                                                                              }else {
                                                                                                  recognizedWordInfo.GetRecognizedCharacter(characterIndex, -1, recognizedCharacterInfo);
      
                                                                                                  System.out.println(" Character: " + recognizedCharacterInfo.getCharacter());
                                                                                                  System.out.println(" Confidence level : " +recognizedCharacterInfo.getCharConfidence());
                                                                                              }
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }
                                                                              System.out.println(" Field Value : " +fieldValue.getAsString());
                                                                          }
                                                                      }
                                                                  }
                                                              }
                                                          }
                                                      }
      
                                                      trace("Geting next Verification group");
                                                      verificationGroup = verificationWorkSet.NextGroup();
                                                  }
      
                                              }
      
                                          }catch (Exception e){
                                              trace("Exception occured in getting next work group");
                                              e.printStackTrace();
                                          }
      
                                          trace("Get next worksets");
                                          //get next work set
                                          verificationWorkSet =  verificationSession.NextWorkSet();
      
                                      }
                                  }
      
                              }catch (Exception e){
      
                                  e.printStackTrace();
                              }
      
      
                          }finally {
                              trace("closing Verification object");
                              verificationSession.Close();
                          }
      
                      } catch (Exception e) {
                          trace("Exception occured in creating verification sessions");
                      }
      
      
      
                  }catch (Exception e){
                      trace ("Exception occured in");
                  }
      
          }catch (Exception e) {
                  // TODO: handle exception
      
                  e.printStackTrace();
          }
          finally {
                  trace("unloading Engine");
                  Engine.Unload();
              }
      
      
      
      }
      
      .

      }

      코드 : 2 프로젝트 사용

      import java.io.File;
      import java.io.IOException;
      import java.sql.BatchUpdateException;
      
      import com.abbyy.FCEngine.*;
      
      public class VerificationStep {
      //same as above
      
          public static void main( String[] args ) 
          {
              // Load Engine 
              try {
                      trace("Loading engine");
                      IEngineLoader engineLoader= Engine.CreateEngineOutprocLoader();
                      IEngine engine = engineLoader.Load(serialNumber,dllPath);
      
                      try{
                          IProject project = engine.OpenProject( projectFolder + "\\flexitest.fcproj" );
      
                          try {
                              IBatch batch = null ; 
                              trace( "Creating Batch..." );
                              IBatches batchs = project.getBatches(); 
                              if (batchs == null || batchs.getCount() == 0){
                                  batch = project.getBatches().AddNew("TestBatch");
                              }
                              batch = batchs.getElement(0);
                              assert(batch == null);
      
                              try{
                                  trace("opening batch");
                                  batch.Open();
      
                                  trace( "Adding pdfs..." );
                           batch.AddImage(projectFolder + "\\don't upload to big .pdf");
      
                                  trace( "Reconizing pdfs..." );
                                  batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeAll,null);
      
                                  trace("Creating Verification object");
                                  try {   
                                      IVerificationSession verificationSession = project.StartVerification(null); 
      
                                      try {
      
                                          //enabling context verification
                                          verificationSession.getOptions().setVerifyFields(true); 
      
                                          //disabling group verification 
                                          verificationSession.getOptions().setVerifyBaseSymbols(false);
                                          verificationSession.getOptions().setVerifyExtraSymbols(false);
      
                                          try {
                                              trace("Get NextWork Set");
                                              IVerificationWorkSet verificationWorkSet =  verificationSession.NextWorkSet();
      
                                              if ( verificationWorkSet == null){
                                                  trace("first verificationWork set is null");
                                              }else {
      
                                                  //process each work set in Verification session
                                                  trace("Processing Work Set");
                                                  while ( verificationWorkSet != null ){
      
                                                      try{
                                                          trace("Geting Verification group");
                                                          //get next group for verification 
                                                          IVerificationGroup verificationGroup = verificationWorkSet.NextGroup(); 
      
                                                          if ( verificationGroup == null ){
                                                              trace("First verification group is null");
                                                          }else {
                                                              trace("processing each group of a workset");
                                                              //processing each group of a work set
                                                              while ( verificationGroup!= null){
                                                                  int verificationObjectInAGroupCount =  verificationGroup.getCount(); 
                                                                  trace("Total number of verification object: " +verificationObjectInAGroupCount);
      
                                                                  for ( int iterator = 0; iterator<verificationObjectInAGroupCount; iterator++){
                                                                      trace ( "getting and Processing "+(iterator +1 ) + " verification object of A group");
      
                                                                      //getting verification object 
                                                                      IVerificationObject verificationObject = verificationGroup.getElement(iterator);
                                                                      if ( verificationObject == null){
                                                                          trace("verification object is null");
                                                                      }else {
                                                                          if ( verificationObject.getType() == VerificationObjectTypeEnum.VOT_Group ) {
                                                                              IGroupVerificationObject groupVerificationObject = verificationObject.AsGroupVerificationObject(); 
      
                                                                              if ( groupVerificationObject == null){
                                                                                  System.out.println("group verification object is null ");
                                                                              }
      
      
                                                                          }else if ( verificationObject.getType() == VerificationObjectTypeEnum.VOT_Context) {
                                                                              IContextVerificationObject  contextVerificationObject = verificationObject.AsContextVerificationObject(); 
      
      
      
                                                                              if ( contextVerificationObject == null){
                                                                                  trace("ContextVerification object is null");
                                                                              }else {
                                                                                  IField field = contextVerificationObject.getField(); 
                                                                                  if ( field == null){
                                                                                      trace("field getting null");
                                                                                  }else {
                                                                                      System.out.println(" field full name: " +field.getFullName() + "\n Name: " +field.getName());
      
                                                                                      IFieldValue fieldValue = field.getValue();
                                                                                      if ( fieldValue == null){
                                                                                          trace("Field Value is Null");
                                                                                          }else {
                                                                                              trace ( "getting text from field value");
                                                                                          IText text = fieldValue.getAsText() ; 
                                                                                          if ( text == null){
                                                                                              trace("text getting null in field value");
                                                                                          }else {
      
                                                                                              int wordCount = text.getRecognizedWordsCount() ; 
                                                                                              trace("recognized word count: "+wordCount);
      
                                                                                              //getting words from text 
                                                                                              for ( int wordIndex = 0 ; wordIndex<wordCount; wordIndex++ ){
                                                                                                  trace ("processing word number :" +wordIndex);
      
                                                                                                  IRecognizedWordInfo recognizedWordInfo = engine.CreateRecognizedWordInfo()  ; 
      
                                                                                                  if ( recognizedWordInfo == null){
                                                                                                      trace("Can't create recognizedWordInfo object using engine");
                                                                                                  }else {
                                                                                                      text.GetRecognizedWord(wordIndex, -1, recognizedWordInfo);
      
                                                                                                      //getting characters from word
                                                                                                      for (int characterIndex = 0 ; characterIndex<recognizedWordInfo.getText().length(); characterIndex++ ){
                                                                                                          trace("processing character number : " +characterIndex);
      
                                                                                                          IRecognizedCharacterInfo recognizedCharacterInfo = engine.CreateRecognizedCharacterInfo(); 
                                                                                                          if ( recognizedCharacterInfo == null) {
                                                                                                              trace("can't create recognizedCharacterInfo object");
                                                                                                          }else {
                                                                                                              recognizedWordInfo.GetRecognizedCharacter(characterIndex, -1, recognizedCharacterInfo);
      
                                                                                                              System.out.println(" Character: " + recognizedCharacterInfo.getCharacter());
                                                                                                              System.out.println(" Confidence level : " +recognizedCharacterInfo.getCharConfidence());
                                                                                                          }
                                                                                                      }
                                                                                                  }
                                                                                              }
                                                                                          }
                                                                                          System.out.println(" Field Value : " +fieldValue.getAsString());
                                                                                      }
                                                                                  }
                                                                              }
                                                                          }
                                                                      }
                                                                  }
      
                                                                  verificationGroup = verificationWorkSet.NextGroup();
                                                              }
      
                                                          }
      
                                                      }catch (Exception e){
      
                                                          e.printStackTrace();
                                                      }
      
                                                     //get next work set
                                                      verificationWorkSet =  verificationSession.NextWorkSet();
      
                                                  }
                                              }
      
                                          }catch (Exception e){
      
                                              e.printStackTrace();
                                          }
      
      
                                      }finally {
                                         verificationSession.Close();
                                      }
                                  }catch (Exception e){
      
                                      e.printStackTrace();
                                  }
      
      
                                  trace ("Getting Documents");
                                  IDocuments documents = batch.getDocuments(); 
      
                                  trace ("Getting Fields and printing");
                                  for ( int j = 0 ; j < documents.getCount(); j++){
                                      trace ("Getting documnets:" +(j+1));
      
                                      IDocument document = documents.getElement(j);
                                      IDocumentDefinition definition = document.getDocumentDefinition();
                                      assert( definition != null );
                                      assert( document.getPages().getCount() == 1 );
      
      
                                      trace( "DocumentType: " + document.getDocumentDefinition().getName() );
      
                                      try {
                                          trace("opening document");
                                          document.Open(true);
                                          IFields fields = document.getSections().Item( 0 ).getChildren();
      
                                          for( int i = 0; i < fields.getCount(); i++ ) {
                                              IField field = fields.getElement( i );
                                              trace( field.getName() + ": " + 
                                                                      ( field.getValue() != null ? field.getValue().getAsString() : "." ) );
                                          }
                                      }finally {
                                          trace("closing document");
                                          document.Close(true);
                                      }
                                  }
                              }finally {
                                      trace("Closing Batch");
                                      batch.Close();
                              }
      
                      }catch (Exception e){
                              System.out.println("Exception in creating Batch");
                              e.printStackTrace();
                      }
                      finally {
                          trace("closing project");
      
                          project.Close();
                      }
      
                      }catch (Exception e){
                          System.out.println("Exception occured while loading project");
                          e.printStackTrace();
                      }
      
              }catch (Exception e) {
                      // TODO: handle exception
                      System.out.println("Exception occured while loading engine");
                      e.printStackTrace();
              }
              finally {
                      trace("unloading Engine");
                      Engine.Unload();
      
                  }
      
          }
      
      
      
      
      }
      
      .

도움이 되었습니까?

해결책

마침내 나는 내 솔루션을 얻었습니다. 실제로 그것은 올바르게 인식하고, 나는 그들을 잘못 취급하는 것입니다 ...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top