-
-
Save thenormalsquid/49f6b4b073bbd37ff639 to your computer and use it in GitHub Desktop.
tess
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
// | |
// FirstViewController.m | |
// Matchmaker | |
// | |
// Created by radicalcakes on 1/2/15. | |
// Copyright (c) 2015 matchmaker. All rights reserved. | |
// | |
#import "FirstViewController.h" | |
#import "ParseImageController.h" | |
@interface FirstViewController () | |
{ | |
Tesseract *tesseract; | |
} | |
@end | |
@implementation FirstViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { | |
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error" | |
message:@"Device has no camera" | |
delegate:nil | |
cancelButtonTitle:@"OK" | |
otherButtonTitles: nil]; | |
[myAlertView show]; | |
} else { | |
tesseract = [[Tesseract alloc] initWithLanguage:@"eng"]; | |
tesseract.delegate = self; | |
} | |
} | |
- (void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (IBAction)takePhoto:(UIButton *)sender { | |
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; | |
picker.delegate = self; | |
picker.allowsEditing = NO; | |
picker.sourceType = UIImagePickerControllerSourceTypeCamera; | |
[self presentViewController:picker animated:YES completion:NULL]; | |
} | |
- (IBAction)selectPhoto:(UIButton *)sender { | |
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; | |
picker.delegate = self; | |
picker.allowsEditing = NO; | |
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; | |
[self presentViewController:picker animated:YES completion:NULL]; | |
} | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { | |
UIImage *chosenImage = [info valueForKey:UIImagePickerControllerOriginalImage]; | |
NSLog(@"%@", chosenImage); | |
NSLog(@"%@", tesseract); | |
tesseract.image = chosenImage; | |
[tesseract recognize]; | |
NSLog(@"fuck"); | |
NSLog(@"%@", [tesseract recognizedText]); | |
//handle the image, save, and parse text out of the image | |
[picker dismissViewControllerAnimated:YES completion:NULL]; | |
//[ParseImageController storeImage:chosenImage]; | |
} | |
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { | |
[picker dismissViewControllerAnimated:YES completion:NULL]; | |
} | |
- (BOOL)shouldCancelImageRecognitionForTesseract:(Tesseract*)tesseract | |
{ | |
NSLog(@"progress: %d", tesseract.progress); | |
return NO; // return YES if you need to interrupt Tesseract before it finishes | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment