egao1980 / tesseract-capi

Low level Tesseract C API wrapper for versions 3.05.02, 4.1.1 and 5.0.0
MIT License
7 stars 0 forks source link

Unhandled memory fault at #x0 when using IMAGE-TO-TEXT #2

Open ghost opened 3 years ago

ghost commented 3 years ago

After installing the Tesseract library (version 4) in my system, and your library:

;; install Ultralisp if you haven't done it yet
(ql-dist:install-dist "http://dist.ultralisp.org/"
                      :prompt nil)

;; install the wrapper code
(ql:quickload :tesseract-capi)

I try to use the image-to-text function

(in-package :tesseract-capi)

(let ((*tessdata-directory* "/usr/share/tesseract-ocr/4.00/tessdata"))
                       (image-to-text #p"pride-and-prejudice.png"))

And get the following error:

Unhandled memory fault at #x0.
   [Condition of type SB-SYS:MEMORY-FAULT-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {10038BC3E3}>)

Backtrace:
  0: (SB-SYS:MEMORY-FAULT-ERROR #<unused argument> #.(SB-SYS:INT-SAP #X00000000))
      Locals:
        SB-KERNEL::ADDRESS-SAP = #.(SB-SYS:INT-SAP #X00000000)
  1: ("foreign function: call_into_lisp")
      [No Locals]
  2: ("foreign function: funcall2")
      [No Locals]
  3: ("foreign function: handle_memory_fault_emulation_trap")
      [No Locals]
  4: ("foreign function: handle_trap")
      [No Locals]
  5: ("foreign function: #x419350")
      [No Locals]
  6: (IMAGE-TO-TEXT #P"pride-and-prejudice.png" :LANG "eng")
      Locals:
        FILEPATH = #P"pride-and-prejudice.png"
        LANG = "eng"
  7: ((LAMBDA ()))
      [No Locals]
  8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) (IMAGE-TO-TEXT #P"pride-and-prejudice.png")) #<NULL-LEXENV>)
      Locals:
        SB-KERNEL:LEXENV = #<NULL-LEXENV>
        SB-IMPL::ORIGINAL-EXP = (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) ..)
  9: (EVAL (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) (IMAGE-TO-TEXT #P"pride-and-prejudice.png")))

I select the Restart number 2, and get:

The value
  NIL
is not of type
  SB-SYS:SYSTEM-AREA-POINTER
when binding SB-ALIEN::VALUE
   [Condition of type TYPE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "new-repl-thread" RUNNING {10038BC3E3}>)

Backtrace:
  0: (TESSBASEAPIEND NIL)
      Locals:
        HANDLE = NIL
  1: ((FLET "CLEANUP-FUN-1" :IN IMAGE-TO-TEXT)) [cleanup]
      [No Locals]
  2: (IMAGE-TO-TEXT #P"pride-and-prejudice.png" :LANG "eng")
      Locals:
        FILEPATH = #P"pride-and-prejudice.png"
        LANG = "eng"
  3: ((LAMBDA ()))
      [No Locals]
  4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) (IMAGE-TO-TEXT #P"pride-and-prejudice.png")) #<NULL-LEXENV>)
      Locals:
        SB-KERNEL:LEXENV = #<NULL-LEXENV>
        SB-IMPL::ORIGINAL-EXP = (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) ..)
  5: (EVAL (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) (IMAGE-TO-TEXT #P"pride-and-prejudice.png")))
      Locals:
        SB-IMPL::ORIGINAL-EXP = (LET ((*TESSDATA-DIRECTORY* "/usr/share/tesseract-ocr/4.00/tessdata")) ..)

Not sure what is happening...

ghost commented 3 years ago

Yesterday I didn't have the time to try another Common Lisp implementation (by the way, I didn't mention that I was using SBCL), but just tried it (using CCL) and it works fine :-)

So it must be a problem with, or related to, SBCL (my current version is SBCL 1.4.16.debian).