4 Replies Latest reply on Feb 27, 2017 12:19 PM by Intel Corporation

    How to install tesseract-ocr on intel edison

    Ramisha93

      I have to install tesseract-OCR on Intel Edison mini-breakout.

       

      I have followed these steps.

       

      opkg install tesseract

       

      installed properly

       

       

      opkg install python-setup tools

       

      root@RamishaEdison:/Intel# opkg install python-setup tools

      Unknown package 'python-setup'.

      Unknown package 'tools'.

      Collected errors:

      * opkg_install_cmd: Cannot install package python-setup.

      * opkg_install_cmd: Cannot install package tools.

       

      opkg install tesseract-ocr

       

      root@RamishaEdison:/Intel# opkg install tesseract-ocr

      Unknown package 'tesseract-ocr'.

      Collected errors:

      * opkg_install_cmd: Cannot install package tesseract-ocr.

      I tried running this python program on Intel Edison

       

      import cv2

      import cv2.cv as cv

      import tesseract

      import numpy as np

      import pyttsx

      import pytesseract

      scr = cv2.imread('/Intel/godisgreat.jpg',0)

      #cv2.imshow('loaded image', scr)

      api = tesseract.TessBaseAPI()

      api.Init(".","eng",tesseract.OEM_DEFAULT)

      api.SetPageSegMode(tesseract.PSM_AUTO)

      image = cv.CreateImageHeader((scr.shape[1],scr.shape[0]), cv.IPL_DEPTH_8U, 1)

      cv.SetData(image, scr.tostring(), scr.dtype.itemsize*scr.shape[1])

      tesseract.SetCvImage(image,api)

      tex=api.GetUTF8Text()

      conf=api.MeanTextConf()

      g=open('god.txt' , 'w')

      g.write(tex)

      g.close()

      g = open("god.txt")

      thegod=g.read()

      with open("god.txt", "r") as f:

          for line in f:

              cleanedLine = line.strip()

              if cleanedLine: # is not empty

                  print(cleanedLine)

      cv2.waitKey(0)

      cv2.destroyAllWindows()

       

      Getting error is

       

      root@RamishaEdison:/Intel# python memsimage.py

      Traceback (most recent call last):

        File "memsimage.py", line 9, in <module>

          api = tesseract.TessBaseAPI()

      AttributeError: 'module' object has no attribute 'TessBaseAPI'

       

      I don't how to solve this

       

      But this same program running well on windows python shell.

        • 1. Re: How to install tesseract-ocr on intel edison
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Ramisha93,
           
          Thanks for reaching out!
           
          The error means that you haven't installed the libraries that the code requires to run. The opkg outputs that you receive say that the packages you are trying to install do not exist on the repo.
           
          I tried to install the required packages, these are the steps I took:
           
          pip install --upgrade pip
          pip install pytesseract
          pip install opencv-python
          pip install pyttsx
          opkg install tesseract tesseract-dbg tesseract-dev tesseract-doc
          pip install tesseract-ocr
           
          I was able to get rid of some errors but the following stayed:
           
          Traceback (most recent call last):
            File "2test.py", line 10, in <module>
              api = tesseract.TessBaseAPI()
          NameError: name 'tesseract' is not defined
           
          Where did you get this code? Which packages did you install in Windows in order to make run it?
           
          Let me know.
          Pedro M.

          • 2. Re: How to install tesseract-ocr on intel edison
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello Ramisha93,

            Do you have any updates about this?

            Pedro M.

            • 3. Re: How to install tesseract-ocr on intel edison
              Ramisha93

              I collected code by googling. I modified the code according to my requirements of project.

              But while running python progrom on windows i it acquires black screen like cmd.exe.

              Still same error is following.

              • 4. Re: How to install tesseract-ocr on intel edison
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Is it possible for your to share the link of the page where you found the code you based your project in?

                I'm afraid I don't understand this sentence:

                "...But while running python progrom on windows i it acquires black screen like cmd.exe…"

                What do you mean by that?

                Did you install any python packages in order to run this code on your PC? If so, which ones and how?

                Let me know.
                Pedro M.