我正在使用 Vision 检测文本,它工作正常我让它在检测到某些东西并调用函数时使用完成,但仍在检测到文本。
如何停止文本检测
要开始它,我正在使用:
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
}