Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

UITextRecognition getting the text upside down - Swift

I'm using the UIText recognition with the .accurate recognition type and it keeps reading the text flipped

for eg. instead of scanning 0606 it scans it as 9090

This is the piece of code

func setUpVisionTextRecognizingImage(image: UIImage){
        
        var textString = ""
        request = VNRecognizeTextRequest(completionHandler: {(request, error) in
            
            guard let observations = request.results as?[VNRecognizedTextObservation] else {fatalError("Recieved Invalid Observaton")}
            
                for observation in observations {
                
                guard let topCandidate = observation.topCandidates(1).first else {print("No Candidate")
                continue
                }
                    textString = "
(topCandidate.string)"
                    print(textString)
                    DispatchQueue.main.async {
                        self.stopAnimating()
                            
                        let (testingVariable, isItFound) = (self.brain.getCode(uneditedCode: textString))
                        
                        
                        if isItFound == true {
                            
                            self.textLabel.text = testingVariable
                            self.buttonPressed(self)
                        }
                        else{self.showTryAgain(message: "try again")}

                        
                        
                    }}})
    
        request.recognitionLevel = .accurate
    let requests = [request]
    
        DispatchQueue.global(qos: .userInitiated).async {
            guard let img = image.cgImage else{fatalError("Missing Image to Scan")}
            let handle = VNImageRequestHandler(cgImage: img, options: [:])
            try?handle.perform(requests)
        }
    
    
    }
question from:https://stackoverflow.com/questions/65886500/uitextrecognition-getting-the-text-upside-down-swift

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...