gali8/Tesseract-OCR-iOS

setenv("TESSDATA_PREFIX", [_absoluteDataPath stringByAppendingString:@"/"].fileSystemRepresentation, 1); _absoluteDataPath is Nil, doesnt work in iOS 12

bawarkamalqader opened this issue · 6 comments

I think G8Tesseract.mm file line 168 is sending the method stringByAppendingString to a nil object .

i changed the code like this and it worked :

if (absoluteDataPath != nil) { [self moveTessdataToDirectoryIfNecessary:absoluteDataPath]; } else { absoluteDataPath = @""; }

This also gives EXC_BAD_ACCESS if tessdata is not found.

Simple fix will be:

`

   if (absoluteDataPath != nil) {
        [self moveTessdataToDirectoryIfNecessary:absoluteDataPath];
        //Fixing moved from the below -> use the supplied absolutePath (to change the location of tssdata only when not nil
        _absoluteDataPath = absoluteDataPath.copy;
    }
    //Absolute path is already set by
    // self = [self initWithLanguage:language engineMode:engineMode];
    // to the bundle location
    //_absoluteDataPath = absoluteDataPath.copy;
    _configDictionary = configDictionary;
    _configFileNames = configFileNames;
    
    setenv("TESSDATA_PREFIX", [_absoluteDataPath stringByAppendingString:@"/"].fileSystemRepresentation, 1);

`

I am having the same issue and the fixes above did not work on iOS 12.1.4? Any luck making it run ? it worked on iOS 10.3.1 simulator

Same problem here. To be honest I didn't really look at the documentation nor spent some time on the project, but i'm a bit surprised the demo app does not even run and crashes.

this is how I fixed it .

  if (absoluteDataPath != nil) {
            [self moveTessdataToDirectoryIfNecessary:absoluteDataPath];
            _absoluteDataPath = absoluteDataPath.copy;
        } else { absoluteDataPath = @""; }
        _configDictionary = configDictionary;
        _configFileNames = configFileNames;
        
        setenv("TESSDATA_PREFIX", [_absoluteDataPath stringByAppendingString:@"/"].fileSystemRepresentation, 1);