title: Swift 3 - Tesseract recognize throwing errors for any image manipulation
body: <p>I am using Swift 3 and developing an application where the user takes a photo and uses Tesseract OCR to recognize the text in it.  </p>
  
  <p>The following code block works.  </p>
  
  <pre><code>func processPhoto() {
      if let tesseract = G8Tesseract(language: "eng") {
          tesseract.delegate = self
  
          // this is the resulting picture gotten after running the capture delegate
          tesseract.image = stillPicture.image!
          tesseract.recognize()
      }
  }
  </code></pre>
  
  <p>However, if I try to manipulate the picture at all (<code>stillPicture.image!</code>), I get the following error: </p>
  
  <pre><code>Error in pixCreateHeader: depth must be {1, 2, 4, 8, 16, 24, 32}
  Error in pixCreateNoInit: pixd not made
  Error in pixCreate: pixd not made
  Error in pixGetData: pix not defined
  Error in pixGetWpl: pix not defined
  2017-03-13 11:13:05.336796 ProjectName[35238:9127211] Cannot convert image to Pix with bpp = 64
  Error in pixSetYRes: pix not defined
  Error in pixGetDimensions: pix not defined
  Error in pixGetColormap: pix not defined
  Error in pixClone: pixs not defined
  Error in pixGetDepth: pix not defined
  Error in pixGetWpl: pix not defined
  Error in pixGetYRes: pix not defined
  Please call SetImage before attempting recognition.Please call SetImage before attempting recognition.2017-03-13 11:13:05.343568 EOB-Reader[35238:9127211] No recognized text. Check that -[Tesseract setImage:] is passed an image bigger than 0x0.
  </code></pre>
  
  <p>Some things that I do to manipulate the picture is to rotate it: </p>
  
  <pre><code>// Rotate taken picture
  let orig_image = stillPicture.image!
  
  let new_image_canvas = UIGraphicsImageRenderer(size: CGSize(width: stillPicture.image!.size.height,
                                                                    height: stillPicture.image!.size.width))
  let new_image = new_image_canvas.image { _ in
      let curr_context = UIGraphicsGetCurrentContext()!
      curr_context.translateBy(x: 0, y: stillPicture.image!.size.width)
      curr_context.rotate(by: -.pi/2)
      stillPicture.image!.draw(at: .zero)
  }
  
  tesseract.image = new_image
  </code></pre>
  
  <p>If I do that, BOOM! The error above occurs.  </p>
  
  <p>Another manipulation I do is to crop portion of the image.</p>
  
  <pre><code>let finalImage : UIImage
  
  let crop_section = CGRect(x: 590.0, y: 280.0, width: 950.0, height: 550.0)
  
  let cg_image = stillPicture.image!.cgImage?.cropping(to: crop_section)
  finalImage = UIImage(cgImage: cg_image!)      
  
  tesseract.image = final_image
  </code></pre>
  
  <p>Again, BOOM! Error appears.  Any idea why this is happening and why my image manipulations are causing problems?  Thanks for your help!  </p>