Skip to content

Commit

Permalink
Merge pull request ldiqual#8 from mvelikov/master
Browse files Browse the repository at this point in the history
Adding clear method to prevent memory leaks
  • Loading branch information
ldiqual committed Jun 14, 2013
2 parents 4f93be0 + 5aefdc6 commit 1a580e6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions Classes/Tesseract.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
- (BOOL)setLanguage:(NSString *)language;
- (BOOL)recognize;
- (NSString *)recognizedText;
- (void)clear;

@end
6 changes: 6 additions & 0 deletions Classes/Tesseract.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ - (NSString *)recognizedText {
return [NSString stringWithUTF8String:utf8Text];
}

- (void)clear
{
_tesseract->Clear();
_tesseract->End();
}

- (void)setImage:(UIImage *)image
{
free(_pixels);
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Here is the default workflow to extract text from an image:
- Set the image to analyze
- Start recognition
- Get recognized text
- Clear


Code Sample
Expand All @@ -48,6 +49,7 @@ Code Sample
[tesseract recognize];

NSLog(@"%@", [tesseract recognizedText]);
[tesseract clear];


Method reference
Expand Down Expand Up @@ -97,3 +99,8 @@ Start text recognition. You might want to launch this process in background with

Get the text extracted from the image.

### -clear ###

`- (void) clear`

Clears Tesseract object after text has been recognized from image. Preventing memory leaks.

0 comments on commit 1a580e6

Please sign in to comment.