title: Tesseract OCR iOS image format
body: <p>I have used Tesseract OCR iOS to scan text, and I have gotten it to work with a photo included in the project.</p>
  
  <p>But when passing it a UIImage from the UIImagePickerController, it does not work. I set up this simple test:</p>
  
  <ol>
  <li>Take the original image from the picker, and feed it to tesseract: Does <strong>not</strong> work.</li>
  <li>Save the UIImage as JPEG, copy it from the app container, include it in the project and feed it to tesseract: Does <strong>not</strong> work.</li>
  <li>Open the saved UIImage in photoshop, and save it again (no changes with default JPEG quality 12 settings). Include it in the project at feed it to tesseract: <strong>Works?!?</strong></li>
  </ol>
  
  <p>Tesseract does recognize the correct amount of lines in the original, but as garbage (i tested several example tests). Once saved in Photoshop the image has a good recognition rate.</p>
  
  <p>I simply cannot figure out what is wrong with the original UIImage that Photoshop somehow fixes. Please help!</p>
  
  <p>Here are the images:</p>
  
  <ul>
  <li><a href="https://dl.dropboxusercontent.com/u/512168/temp_ocr_image_orig.jpg">Original image</a></li>
  <li><a href="https://dl.dropboxusercontent.com/u/512168/temp_ocr_image_photoshoped.jpg">Photoshopped image</a></li>
  </ul>
  
  <p>The code for feeding images to tesseract:</p>
  
  <pre><code>- (void)recognizeWithImage:(UIImage *)image {
      G8RecognitionOperation *operation = [[G8RecognitionOperation alloc] initWithLanguage:@"dan"];
      operation.tesseract.image = image;
      self.imageView.image = image;
      operation.recognitionCompleteBlock = ^(G8Tesseract *recognizedTesseract) {
          NSLog(@"Result:\n%@", [recognizedTesseract recognizedText]);
      };
      NSOperationQueue *queue = [[NSOperationQueue alloc] init];
      [queue addOperation:operation];
  }</code></pre>
  
  <p>Here is the code for getting the image from camera:</p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      [self dismissViewControllerAnimated:YES completion:nil];
      UIImage *originalImage = info[UIImagePickerControllerOriginalImage];
  
      NSData *dataForJPEGFile = UIImageJPEGRepresentation(originalImage, 1.0);
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *filePath = [paths[0] stringByAppendingPathComponent:@"temp_ocr_image_orig.jpg"];
      [dataForJPEGFile writeToFile:filePath atomically:YES];
  
      [self recognizeWithImage:originalImage];
  }</code></pre>
  
  <p>And the testing of the two image files:</p>
  
  <pre><code>[self recognizeWithImage:[UIImage imageNamed:@"temp_ocr_image_orig.jpg"]];
  [self recognizeWithImage:[UIImage imageNamed:@"temp_ocr_image_photoshopped.jpg"]];</code></pre>