Tesseract OCR iOS preprocessedImageForTesseract delegate is not being called, or at least I think it's not being called.
Consider the following Swift code:
class Ocr: NSObject, G8TesseractDelegate {
func process(image: UIImage) -> UIImage {
let tesseract = G8Tesseract.init(language: "eng")
tesseract.delegate = self
tesseract.image = image
tesseract.recognize()
retu tesseract.image
}
func shouldCancelImageRecognitionForTesseract(tesseract: G8Tesseract!) -> Bool {
print("cancelImage delegate called")
retu false
}
func preprocessedImageForTesseract(tesseract: G8Tesseract, image: UIImage) -> UIImage {
print("preprocessedImage deletegate called")
retu image
}
}
If I just call the function process from the viewController with a sample image given by the camera, the preprocessedImageForTesseract is never called after setting the image. To check whether any delegates are actually working I have included shouldCancelImageRecognitionForTesseract; I can confirm that this delegate works. Not only I'm using print function to check whether they are being called, I've also used breakpoints which shows the same problem.
I know for a fact that Tesseract does recognise correctly from the live camera feed image, but I've just noticed that it's not calling that delegate. This is a conce because Tesseract might be performing uecessary threshold on the live feed which changes results I wanted. I'm performing my own image preprocessing so I don't want any unexpected behaviour.
Some extra info:
-
OS: Mac OS X El Capitan
-
iOS: iPhone 6 iOS 9
-
Installed from CocoaPods.
Podfile:
use_frameworks!
pod 'TesseractOCRiOS', '4.0.0'
pod 'GPUImage', '0.1.7'
