Comments (2)
Cute avatar! I love limbo :)
You can use the shouldCancelImageRecognitionForTesseract delegate for now.
I'm working for your request.
from tesseract-ocr-ios.
Haha, thanks :) I love limbo too :)
Actually I'm making an app which must recognize text in "real time".
E.g. something link in this video https://www.youtube.com/watch?v=c7swRRLlYEo :)
Here is my code:
#define kScanTimeInterval 0.5f
//...
- (void)createScanner
{
self.scanner = nil;
self.scanner = [[Tesseract alloc] initWithLanguage:@"swe"];
[self.scanner setVariableValue:@"0123456789# ->,AaBbCcDdEeFfGgIiJjKkLlMmNnOoPpRrSsTtUuVv" forKey:@"tessedit_char_whitelist"];
// [self.scanner setVariableValue:@"±@$%^§&*+=[]{}'|?~" forKey:@"tessedit_char_blacklist"];
self.scanner.delegate = self;
self.grayScaleFilter = [[GPUImageGrayscaleFilter alloc] init];
}
- (void)prepareToScan
{
self.timer = [[MSWeakTimer alloc] initWithTimeInterval:kScanTimeInterval
target:self
selector:@selector(timerTicked)
userInfo:nil
repeats:YES
dispatchQueue:dispatch_get_main_queue()];
[self.timer schedule];
[self.captureSession startRunning];
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection;
{
if (canScanFrame) {
canScanFrame = NO;
UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
image = [UIImage imageByCropping:image toRect:self.rectForScanning];
image = [self.grayScaleFilter imageByFilteringImage:image];
[self.scanner setImage:image];
isScanning = YES;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSLog(@"scan start");
[self.scanner recognize];
NSLog(@"scan stop");
dispatch_async(dispatch_get_main_queue(), ^{
isScanning = NO;
NSString *text = [self.scanner recognizedText];
if (self.delegate && [self.delegate respondsToSelector:@selector(ocrScanner:didScanWithResult:forImage:)]) {
[self.delegate ocrScanner:self didScanWithResult:text forImage:image];
}
});
});
}
}
- (void)timerTicked
{
if (!isScanning) {
canScanFrame = YES;
}
}
In my case I know that the scanning frame are small (because I crop them), and that the text that I'm scanning is also a small text, but sometimes scanning process for 1 specific frame takes a lot of time (~5secs). I don't know, may be because of the camera shakes and the image not much clear to recognize?
Here I thought about setting time out for recognizing time (which in my case should not exceed 1 sec) which will optimise scanning process.
Or, it will be even better, also to set limitation of characters count that must be scanned. Say, I know that the text that user must scan can be max 20 of length, but tesseract returns a lot of symbols (like ~,$± etc) after 5 seconds of recognizing.
So, if I set the timeOut to 1 second, and maxRecognizedTextLength to 20, then the scanning process will be much more faster and accurate :)
from tesseract-ocr-ios.
Related Issues (20)
- .
- User-Words file not loaded: Error: failed to load user-words HOT 5
- doesn't work with 64bpp images
- pod failed HOT 1
- Does not detects images 100%
- What's means with *.cube.* ? e.g. eng.cube.fold
- Why does the testsdata folder exist in the project? HOT 2
- Why don't we upgrade to the latest Tesseract?
- cocoapods 5.0.1 error
- Xcode 12.0.1 build is failing when trying to run it on the simulator. HOT 2
- RecognitionQuestion
- Apple Silicon (arm64; M1) support HOT 2
- Thread 1: EXC_BAD_ACCESS (code=1, address=0x163940000)
- Framework not found for Mac OS HOT 1
- 你好 这句一定闪退
- PDF creation not working
- self.tesseract!.recognize() is crashing in Acuant MRZ
- How to update Tesseract version
- Target 'TesseractOCRiOS' (project 'Pods') has copy command HOT 1
- cannot load language 'eng' HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tesseract-ocr-ios.