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];
|
[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 * 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,
|
char* text = tess_base_api.TesseractRect(image,
|
||||||
(int)bytes_per_pixel,
|
(int)bytes_per_pixel,
|
||||||
@@ -68,7 +69,6 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)tessdataAvailableForLanguage:(NSString *)language
|
- (BOOL)tessdataAvailableForLanguage:(NSString *)language
|
||||||
@@ -87,11 +87,9 @@ protected:
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init])) {
|
||||||
{
|
|
||||||
tess_base = (void *)new OCRWrapper(lang_for_english([_language UTF8String])->iso639_2, NULL);
|
tess_base = (void *)new OCRWrapper(lang_for_english([_language UTF8String])->iso639_2, NULL);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@@ -99,8 +97,7 @@ protected:
|
|||||||
|
|
||||||
- (instancetype)initWithLanguage:(NSString *)language
|
- (instancetype)initWithLanguage:(NSString *)language
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init])) {
|
||||||
{
|
|
||||||
_language = [language retain];
|
_language = [language retain];
|
||||||
|
|
||||||
NSString *lang = [NSString stringWithUTF8String:lang_for_english([_language UTF8String])->iso639_2];
|
NSString *lang = [NSString stringWithUTF8String:lang_for_english([_language UTF8String])->iso639_2];
|
||||||
@@ -116,7 +113,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)performOCROnCGImage:(CGImageRef)cgImage {
|
- (NSString *)performOCROnCGImage:(CGImageRef)cgImage {
|
||||||
NSMutableString * text;
|
NSMutableString *text = nil;
|
||||||
|
|
||||||
OCRWrapper *ocr = (OCRWrapper *)tess_base;
|
OCRWrapper *ocr = (OCRWrapper *)tess_base;
|
||||||
size_t bytes_per_line = CGImageGetBytesPerRow(cgImage);
|
size_t bytes_per_line = CGImageGetBytesPerRow(cgImage);
|
||||||
@@ -136,16 +133,13 @@ protected:
|
|||||||
|
|
||||||
if (string && strlen(string)) {
|
if (string && strlen(string)) {
|
||||||
text = [NSMutableString stringWithUTF8String: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])];
|
[text replaceOccurrencesOfString:@"\n\n" withString:@"" options:nil range:NSMakeRange(0,[text length])];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
text = nil;
|
|
||||||
|
|
||||||
delete[]string;
|
delete[]string;
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
@@ -156,4 +150,5 @@ protected:
|
|||||||
[_language release];
|
[_language release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
Reference in new issue
Block a user