Tesseract-OCR-iOS icon indicating copy to clipboard operation
Tesseract-OCR-iOS copied to clipboard

Can't analyse layout. Make sure 'osd.traineddata' available in 'tessdata'.

Open CharlesHGong opened this issue 8 years ago • 1 comments

I have osd.traineddata in tessdata folder however, I can't do analyse layout and the program spill out the following error "Can't analyse layout. Make sure 'osd.traineddata' available in 'tessdata'".

here is my code ` func TesseractSetUp() { tesseract.setVariableValue("user_words", forKey: kG8ParamUserWordsSuffix) tesseract.setVariableValue("user_patterns", forKey: kG8ParamUserPatternsSuffix) //tesseract.language = "eng+ita"; //tesseract.delegate = self; tesseract.pageSegmentationMode = G8PageSegmentationMode.osdOnly; tesseract.engineMode = G8OCREngineMode.tesseractOnly; //tesseract.charWhitelist = "01234567890()*&^%#@!~{}[]qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM,.:$-_"; tesseract.charBlacklist = "?/" NSLog("%@", "TesseractSetup"); }

func RecognizeWithTesserract( image_Ori: UIImage){
    TesseractSetUp();
    NSLog("%@", "Starting OCR");
    tesseract.image = image_Ori;
    tesseract.analyseLayout();
    NSLog("%f", tesseract.deskewAngle.native);
    tesseract.recognize();
    
    NSLog("%@", tesseract.recognizedText);
    //NSLog("%@", tesseract.recognizedHOCR(forPageNumber: 0));
    
    // Spawn an alert with the recognized text
    
    let alert = UIAlertController(title: "Show Message", message: tesseract.recognizedText, preferredStyle: UIAlertControllerStyle.alert)
    
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (action: UIAlertAction!) in
        alert .dismiss(animated: true, completion: nil)
    }))
    
    present(alert, animated: true, completion: nil)
    
    imageView.image = tesseract.image(withBlocks: tesseract.recognizedBlocks(by: G8PageIteratorLevel.textline), drawText: true, thresholded: true);
    
}`

CharlesHGong avatar Feb 04 '17 00:02 CharlesHGong

@libra34567, did you find a solution?

mark-bragg avatar Mar 12 '19 22:03 mark-bragg