I am detecting text with Vision and it is working ok I have it use a completion when something detected and call a function, but the text is still being detected.
How can I stop the text detection
To start it i am using:
func startTextDetection() {
let textRequest = VNDetectTextRectanglesRequest(completionHandler: self.detectTextHandler)
textRequest.reportCharacterBoxes = true
self.requests = [textRequest]
}
// I tried this to stop it but it only hides the boxes around the text.
//func stopTextDetection() {
// let textRequest = VNDetectTextRectanglesRequest(completionHandler: //self.detectTextHandler)
// textRequest.reportCharacterBoxes = false
// self.requests = [textRequest]
//}
func detectTextHandler(request: VNRequest, error: Error?) {
guard let observations = request.results else {
print("no result")
return
}
I was able to figure this out by adding the following functions and call it when detection is reached.