 <p>The <code>image</code> on a <code>UIImageView</code> is an <code>UIImage</code> optional, meaning that it can have a value (contain an image) or it can be <code>nil</code>.</p> <p>So, when you're saying:</p> <pre><code>let ocrSample = myImageView.image </code></pre> <p>your <code>ocrSample</code> is now an <code>UIImage</code> optional, which you then have to unwrap before you use it.</p> <p>When you then say:</p> <pre><code>tesseract.image = ocrSample!.fixOrientation().g8_blackAndWhite() </code></pre> <p>you are force unwrapping your <code>ocrSample</code> by using <code>!</code>, meaning that you are telling the compiler to just unwrap and use the optional, regardless of it being <code>nil</code> or not. This causes a crash when you then try to use that unwrapped optional if it contains <code>nil</code>.</p> <p>What you can do is unwrap <code>ocrSample</code> using an <code>if let</code> like so:</p> <pre><code>func checkWithOCR() throws{ if let ocrSample = myImageView.image { tesseract.image = ocrSample.fixOrientation().g8_blackAndWhite() if(tesseract.recognize()){ let recognizedText = tesseract.recognizedText if recognizedText != nil{ print("recognizedText: \(recognizedText)") let trimmedText = String(recognizedText.characters.filter { !" \n\t\r,".characters.contains($0) }) myImageView.image = tesseract.image convertCurrency(Float(trimmedText)!) //convert the tesseract text } } SwiftSpinner.hide() } else { //No value could be found, do your error handling here } } </code></pre> <p>Here:</p> <pre><code>if let ocrSample = myImageView.image </code></pre> <p>you are trying to unwrap the value of <code>myImageView.image</code> into <code>ocrSample</code>, if that succeeds, then you know for sure that <code>ocrSample</code> is not <code>nil</code> and can use it onwards. If it fails, then you can do your error handling, show an alert view and whatever else you need to do.</p> <p>Hope that helps you.</p>