patterns argument is null

  • 2K Views
  • Last Post 28 March 2014
zx344819350 posted this 26 March 2014

i have a project by Xcode 5.1,and run on iOS 7. when i recognize without custom languages,things goes perfect. but when i using a custom languages,a error message come out: patterns argument is null. below is how i create CMocrRecognitionConfiguration.

- (CMocrRecognitionConfiguration*) bcrConfiguration2
{
CMocrUserLanguage* myLanguage = [CMocrUserLanguage languageWithId:1024];
CMocrRecognitionConfiguration* recognitionConfiguration = [[CMocrRecognitionConfiguration alloc]
                                                           initWithImageResolution:0
                                                           imageProcessingOptions:0
                                                           recognitionMode:MRM_Full
                                                           recognitionConfidenceLevel:MRCL_Level3
                                                           barcodeTypes:0
                                                           defaultCodePage:MSCP_Utf8
                                                           unknownLetter:L'^'
                                                           recognitionLanguages:nil];
NSSet* userLanguages = [NSSet setWithObject:myLanguage];
[recognitionConfiguration setUserRecognitionLanguages:userLanguages patternsDataFileName:@"Idcard"];
return recognitionConfiguration;

}

the Idcard.rom is putted into the folder "Pattern"

Julia Anikushina posted this 28 March 2014

To recognize with a custom language try to use the code below:

-(CMocrRecognitionConfiguration*)
{
if(_ocrConfiguration==nil){
    CMocrUserLanguage* myLanguage = [CMocrUserLanguage languageWithId:1024];
    _ocrConfiguration = [[CMocrRecognitionConfiguration alloc]]
        initWithImageResolution:0
        imageProcessingOptions:0
        recognitionMode:MRM_Full
        recognitionConfidenceLevel:MRCL_Level3
        barcodeTypes:0
        defaultCodePage:MSCP_Utf8
        unknownLetter:L'^'
        recognitionLanguages:nil];
    NSSet*userLanguages = [NSSet setWithObjects:myLanguage, nil]
    [_ocrConfiguration setUserRecognitionLanguages:userLanguages     patternsDataFileName:@"UserPattern"];
}
return _ocrConfiguration;
}

Also please check if CMocrRecognitionConfiguration is correctly send for recognition.

Close