Skip to content

Commit

Permalink
Merge pull request gali8#190 from mgratzer/master
Browse files Browse the repository at this point in the history
Added missing 'preprocessedImageForTesseract:sourceImage:' delegate forwarding.
  • Loading branch information
Kevin Conley committed Jul 3, 2015
2 parents f24bb99 + 68ab10f commit b3835a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions TesseractOCR/G8RecognitionOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@ - (BOOL)shouldCancelImageRecognitionForTesseract:(G8Tesseract *)tesseract
return canceled;
}

- (UIImage *)preprocessedImageForTesseract:(G8Tesseract *)tesseract sourceImage:(UIImage *)sourceImage
{
if ([self.delegate respondsToSelector:@selector(preprocessedImageForTesseract:sourceImage:)]) {
return [self.delegate preprocessedImageForTesseract:tesseract sourceImage:sourceImage];
}
return nil;
}

@end
17 changes: 16 additions & 1 deletion TestsProject/TestsProjectTests/G8RecognitionTestsHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
@interface G8RecognitionTestsHelper ()

@property (nonatomic, strong, readwrite) G8Tesseract *tesseract;
@property (nonatomic) BOOL progressDelegateCallbackCalledByQueue;
@property (nonatomic) BOOL cancelDelegateCallbackCalledByQueue;
@property (nonatomic) BOOL preprocessingDelegateCallbackCalledByQueue;

@end

Expand Down Expand Up @@ -125,6 +128,15 @@ - (void)recognizeImageUsingOperation

NSAssert(recognitionCompleteBlockInvoked == YES, @"Error! recognitionCompleteBlock has not been invoked");
NSAssert(progressCallbackBlockInvoked == YES, @"Error! progressCallbackBlock has not been invoked");

NSAssert(self.progressDelegateCallbackCalledByQueue == YES, @"Error! progressImageRecognitionForTesseract has not been invoked by queue");
self.progressDelegateCallbackCalledByQueue = NO;

NSAssert(self.cancelDelegateCallbackCalledByQueue == YES, @"Error! shouldCancelImageRecognitionForTesseract has not been invoked by queue");
self.cancelDelegateCallbackCalledByQueue = NO;

NSAssert(self.preprocessingDelegateCallbackCalledByQueue == YES, @"Error! preprocessedImageForTesseract has not been invoked by queue");
self.preprocessingDelegateCallbackCalledByQueue = NO;
};

- (UIImage *)thresholdedImageForImage:(UIImage *)sourceImage
Expand All @@ -142,16 +154,19 @@ - (UIImage *)thresholdedImageForImage:(UIImage *)sourceImage

- (void)progressImageRecognitionForTesseract:(G8Tesseract *)tesseract
{

self.progressDelegateCallbackCalledByQueue = YES;
}

- (BOOL)shouldCancelImageRecognitionForTesseract:(G8Tesseract *)tesseract
{
self.cancelDelegateCallbackCalledByQueue = YES;
return NO;
}

- (UIImage *)preprocessedImageForTesseract:(G8Tesseract *)tesseract sourceImage:(UIImage *)sourceImage
{
self.preprocessingDelegateCallbackCalledByQueue = YES;

switch (self.customPreprocessingType) {
case G8CustomPreprocessingNone:
return nil;
Expand Down

0 comments on commit b3835a2

Please sign in to comment.