Search code examples
iostesseract

iOS - Tesseract - unable to read cube language model Cube ERROR (CubeRecoContext::Create): unable to init CubeRecoContext object


I am trying to make a Japanese OCR app. I am getting this error while i try to initialize Tesseract. Below are my code:

if let tesseract = G8Tesseract(language: "eng+jpn") {
    tesseract.engineMode = .tesseractCubeCombined
    tesseract.pageSegmentationMode = .auto
    tesseract.image = image.g8_blackAndWhite()
    tesseract.recognize()
    textView.text = tesseract.recognizedText
}

Finally i figured out that i don't have cube files and i couldn't find searching them on github and other's site . Can anyone give me any link where i can find cube files for other language ???


Solution

  • Cube files are not available for all language. As i used

    tesseract.engineMode = .tesseractCubeCombined 
    

    the above code, it will try to use both cube file and regular .traineddata file . To solve this problem , i had to replace the above code as below and add only the langdata as .traineddata format for the specific language under a folder named tessdata

    tesseract.engineMode = .tesseractOnly