gali8 / Tesseract-OCR-iOS

Tesseract OCR iOS is a Framework for iOS7+, compiled also for armv7s and arm64.
http://www.nexor.it
MIT License
4.22k stars 949 forks source link

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

Open bawarkamalqader opened 5 years ago

bawarkamalqader commented 5 years ago

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 = @""; }

recepkocur commented 5 years ago

+1

Gentoli commented 5 years ago

This also gives EXC_BAD_ACCESS if tessdata is not found.

nikolayds commented 5 years ago

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);

`

SebastianKumor commented 5 years ago

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

altimac commented 5 years ago

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.

SebastianKumor commented 5 years ago

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);