Cosmetics.
This commit is contained in:
1 parent
11fb52b090
commit
697ce1f854
1 file changed
+6
-11
+6
-11
@@ -32,6 +32,7 @@ OCRWrapper(const char* lang, const char* base_path) {
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
char * OCRFrame(const unsigned char *image, size_t bytes_per_pixel, size_t bytes_per_line, size_t width, size_t height) {
|
||||
char* text = tess_base_api.TesseractRect(image,
|
||||
(int)bytes_per_pixel,
|
||||
@@ -68,7 +69,6 @@ protected:
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)tessdataAvailableForLanguage:(NSString *)language
|
||||
@@ -87,11 +87,9 @@ protected:
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
tess_base = (void *)new OCRWrapper(lang_for_english([_language UTF8String])->iso639_2, NULL);
|
||||
}
|
||||
return self;
|
||||
@@ -99,8 +97,7 @@ protected:
|
||||
|
||||
- (instancetype)initWithLanguage:(NSString *)language
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_language = [language retain];
|
||||
|
||||
NSString *lang = [NSString stringWithUTF8String:lang_for_english([_language UTF8String])->iso639_2];
|
||||
@@ -116,7 +113,7 @@ protected:
|
||||
}
|
||||
|
||||
- (NSString *)performOCROnCGImage:(CGImageRef)cgImage {
|
||||
NSMutableString * text;
|
||||
NSMutableString *text = nil;
|
||||
|
||||
OCRWrapper *ocr = (OCRWrapper *)tess_base;
|
||||
size_t bytes_per_line = CGImageGetBytesPerRow(cgImage);
|
||||
@@ -136,16 +133,13 @@ protected:
|
||||
|
||||
if (string && strlen(string)) {
|
||||
text = [NSMutableString stringWithUTF8String:string];
|
||||
if ([text characterAtIndex:[text length] -1] == '\n')
|
||||
if (text && [text characterAtIndex:[text length] -1] == '\n')
|
||||
[text replaceOccurrencesOfString:@"\n\n" withString:@"" options:nil range:NSMakeRange(0,[text length])];
|
||||
}
|
||||
else
|
||||
text = nil;
|
||||
|
||||
delete[]string;
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
@@ -156,4 +150,5 @@ protected:
|
||||
[_language release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user