iOSでOCRを使用(Tesseract)
OCRについて必要になったので、色々と調査
手順を抜粋すると以下内容で良いみたい
①tesseract-ocrのインポート
②tesseract-ios」のインポート※ラッパークラス
③プロジェクトの設定
・C++ Language Dialect - Compiler Default
・C++ Standard Library - Compiler Default
④言語ファイルのインポート
⑤実装
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; // OCR実行 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // 日本語を設定 Tesseract *tesseract = [[Tesseract alloc] initWithDataPath:@"tessdata" language:@"jpn"]; // OCRを実行する画像を設定 [tesseract setImage:self.imageView.image]; // OCR実行! [tesseract recognize]; // 実行結果をアラートビューで表示 dispatch_async(dispatch_get_main_queue(), ^{ [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [[[UIAlertView alloc] initWithTitle:@"Tesseract Sample" message:[NSString stringWithFormat:@"Recognized:\n%@", [tesseract recognizedText]] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil] show]; }); }); }
【参考】
Tesseract ocr - http://www.slideshare.net/takmin/tesseract-ocr
→SlideShareがまとめられて、わかりやすい。
OCRのライブラリに関して調査をしてみたのでまとめ - NAVER まとめ - http://matome.naver.jp/odai/2136642604546660501
gali8/Tesseract-OCR-iOS · GitHub - https://github.com/gali8/Tesseract-OCR-iOS
→サンプルソース
Downloads - tesseract-ocr - An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google. - Google Project Hosting - http://code.google.com/p/tesseract-ocr/downloads/list
→ダウンロードリンク先
iOSで日本語OCR!サンプルアプリ構築編〜iOS SDK 6.1 + tesseract-ocr 3.02〜 | Developers.IO - http://dev.classmethod.jp/etc/ios-tesseract-ocr-2/
→サンプルで動かす方法
以上、花粉症にはなっていない堀でした。