I am integrating Tesseract OCR with my Java Spring application and 
encountered an issue where the application prints error messages related to 
ERROR_PTR to the console. My goal is to suppress these error messages to 
prevent them from being displayed.
Steps Taken
   
   1. 
   
   *Loading Native Library for Error Suppression:*
   - Created a custom native library (liberrorsuppressor.so) to suppress 
      the error messages.
      - Compiled the library and placed it in the native directory of the 
      project.
      - Configured DYLD_LIBRARY_PATH and java.library.path to include the 
      path to the custom library.
      - Modified the OCRScanner class to load the native library using 
      System.loadLibrary("errorsuppressor").
   2. 
   
   *Java Configuration:*
   - Set the DYLD_LIBRARY_PATH to 
      /Users/oran.mor/workspace/server-services/services/dlp/native.
      - Set the java.library.path to 
      /Users/oran.mor/workspace/server-services/services/dlp/native.
   3. 
   
   *Adjustments in Code:*
   - Modified the OCRScanner class:
      java
      Copy code
      static { System.loadLibrary("errorsuppressor"); } 
      - Attempted to load the native library but encountered 
      java.lang.UnsatisfiedLinkError indicating the library could not be found 
in 
      the specified paths.
   4. 
   
   *Command-Line Configuration:*
   - Attempted to run the application with additional VM options:
      bash
      Copy code
      bootRun -x test 
      
-Djava.library.path=/Users/oran.mor/workspace/server-services/services/dlp/native/
 
      
      5. 
   
   *Creating and Using the Library:*
   - Created a bin directory and compiled the custom library as 
      libtcnative-1.dylib.
      - Placed the library in the bin directory and updated the 
      System.loadLibrary("tcnative-1") line in the OCRScanner class.
   6. 
   
   *Handling Error Output Directly:*
   - Attempted to redirect System.err in the main method to suppress 
      specific error messages containing "ERROR_PTR":
      java
      Copy code
      System.setErr(new PrintStream(System.out) { @Override public void 
      println(String x) { if (!x.contains("ERROR_PTR")) { super.println(x); } } 
      }); 
      7. 
   
   *Custom Logger Configuration:*
   - Tried to configure Log4j and Logback to filter out specific error 
      messages:
         - Log4j example:
         xml
         Copy code
         <Filters> <RegexFilter regex=".*ERROR_PTR.*" onMatch="DENY" 
         onMismatch="ACCEPT"/> </Filters> 
         - Logback example:
         xml
         Copy code
         <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> 
         <evaluator> <expression>return 
message.contains("ERROR_PTR");</expression> 
         </evaluator> <onMatch>DENY</onMatch> <onMismatch>NEUTRAL</onMismatch> 
         </filter> 
         
Current Status

Despite the various methods attempted, the application still prints the 
ERROR_PTR messages to the console, and the libtcnative-1 library could not 
be loaded successfully. I am seeking advice on alternative methods or 
corrections to the steps taken to suppress these error messages effectively 
in a Java Spring application integrated with Tesseract OCR.

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tesseract-ocr+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/bab2f2ee-3c09-4d6f-a669-9dd34a9e75adn%40googlegroups.com.

Reply via email to