blinkinput / blinkinput-ios

OCR SDK for iOS powered by MicroBlink
Apache License 2.0
130 stars 26 forks source link

PPOcrEngineOptions with charWhiteList doesn't appear to be working #26

Closed hipwelljo closed 7 years ago

hipwelljo commented 7 years ago

It seems that charWhiteList isn't working. I would like it to only show results on the camera feed that are letters A-Z, looking for 8 in a row. But it's showing everything that's recognized as any symbol. Am I missing something in my implementation? I'm using v2.2.0. Thanks!

PPRegexOcrParserFactory *regexParser = [[PPRegexOcrParserFactory alloc] initWithRegex:@"[A-Z]{8}"];
regexParser.isRequired = YES;

PPOcrEngineOptions *options = [[PPOcrEngineOptions alloc] init];
options.charWhitelist = [self uppercaseLetters];
[regexParser setOptions:options];

[ocrRecognizerSettings addOcrParser:regexParser name:self.regexParserId];

- (NSMutableSet *)uppercaseLetters {
    NSMutableSet *charWhitelist = [[NSMutableSet alloc] init];

    for (int c = 'A'; c <= 'Z'; c++) {
        [charWhitelist addObject:[PPOcrCharKey keyWithCode:c font:PP_OCR_FONT_ANY]];
    }

    return charWhitelist;
}
hipwelljo commented 7 years ago

I see, it's working, it's only showing capital letters on the feed as specified. :) Is there a way to get it to only show the results on the camera feed that match the provided regex? So only show recognized 8 capital letters in a row, not 1 letter here, 2 letters over there?

ghost commented 7 years ago

Hi @hipwelljo

default implementation of PPOcrResultOverlaySubview shows all recognized characters, so to do that you would have to implement your own overlay subview.