forked from gali8/Tesseract-OCR-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new-features: Add G8RecognizedBlock for data returned by characterBox…
…es and confidencesByIteratorLevel:
- Loading branch information
Showing
12 changed files
with
228 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Products/TesseractOCR.framework/Versions/A/Headers/G8RecognizedBlock.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// G8RecognizedBlock.h | ||
// Tesseract OCR iOS | ||
// | ||
// Created by Nikolay Volosatov on 18.12.14. | ||
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "G8Constants.h" | ||
|
||
@interface G8RecognizedBlock : NSObject <NSCopying> | ||
|
||
@property (nonatomic, copy, readonly) NSString *text; | ||
@property (nonatomic, assign, readonly) CGRect boundingBox; | ||
@property (nonatomic, assign, readonly) CGFloat confidence; | ||
@property (nonatomic, assign, readonly) G8PageIteratorLevel level; | ||
|
||
- (instancetype)initWithText:(NSString *)text | ||
boundingBox:(CGRect)boundingBox | ||
confidence:(CGFloat)confidence | ||
level:(G8PageIteratorLevel)level; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// G8RecognizedBlock.h | ||
// Tesseract OCR iOS | ||
// | ||
// Created by Nikolay Volosatov on 18.12.14. | ||
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "G8Constants.h" | ||
|
||
@interface G8RecognizedBlock : NSObject <NSCopying> | ||
|
||
@property (nonatomic, copy, readonly) NSString *text; | ||
@property (nonatomic, assign, readonly) CGRect boundingBox; | ||
@property (nonatomic, assign, readonly) CGFloat confidence; | ||
@property (nonatomic, assign, readonly) G8PageIteratorLevel level; | ||
|
||
- (instancetype)initWithText:(NSString *)text | ||
boundingBox:(CGRect)boundingBox | ||
confidence:(CGFloat)confidence | ||
level:(G8PageIteratorLevel)level; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// G8RecognizedBlock.m | ||
// Tesseract OCR iOS | ||
// | ||
// Created by Nikolay Volosatov on 18.12.14. | ||
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. All rights reserved. | ||
// | ||
|
||
#import "G8RecognizedBlock.h" | ||
|
||
@interface G8RecognizedBlock () | ||
|
||
@property (nonatomic, copy) NSString *text; | ||
@property (nonatomic, assign) CGRect boundingBox; | ||
@property (nonatomic, assign) CGFloat confidence; | ||
@property (nonatomic, assign) G8PageIteratorLevel level; | ||
|
||
@end | ||
|
||
@implementation G8RecognizedBlock | ||
|
||
- (instancetype)init | ||
{ | ||
return [self initWithText:nil | ||
boundingBox:CGRectZero | ||
confidence:0.0f | ||
level:G8PageIteratorLevelBlock]; | ||
} | ||
|
||
- (instancetype)initWithText:(NSString *)text | ||
boundingBox:(CGRect)boundingBox | ||
confidence:(CGFloat)confidence | ||
level:(G8PageIteratorLevel)level | ||
{ | ||
self = [super init]; | ||
if (self != nil) { | ||
_text = [text copy]; | ||
_boundingBox = boundingBox; | ||
_confidence = confidence; | ||
_level = level; | ||
} | ||
return self; | ||
} | ||
|
||
- (id)copyWithZone:(NSZone *)zone | ||
{ | ||
return self; | ||
} | ||
|
||
- (BOOL)isEqual:(id)other | ||
{ | ||
if (other == self) { | ||
return YES; | ||
} | ||
else if ([super isEqual:other] == NO) { | ||
return NO; | ||
} | ||
else if ([other isKindOfClass:[self class]] == NO) { | ||
return NO; | ||
} | ||
else { | ||
G8RecognizedBlock *otherBlock = other; | ||
|
||
BOOL result = self.level == otherBlock.level; | ||
result = result && ABS(self.confidence - otherBlock.confidence) < FLT_EPSILON; | ||
result = result && CGRectEqualToRect(self.boundingBox, otherBlock.boundingBox); | ||
result = result && (self.text == otherBlock.text || [self.text isEqual:otherBlock.text]); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
- (NSUInteger)hash | ||
{ | ||
return self.level + (NSUInteger)(self.confidence * 10000) * 11813 + self.text.hash * 13411; | ||
} | ||
|
||
- (NSString *)description | ||
{ | ||
return [NSString stringWithFormat:@"(%.2f%%) '%@'", self.confidence, self.text]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.