This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let requestHandler = VNImageRequestHandler(url: inputImageURL) | |
let request = VNDetectRectanglesRequest { request, error in | |
self.completedVisionRequest(request, error: error) | |
} | |
// perform additional request configuration | |
request.usesCPUOnly = false //allow Vision to utilize the GPU | |
DispatchQueue.global().async { | |
do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pixelBuffer = sceneView?.session.currentFrame?.capturedImage | |
let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .up) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let request = VNDetectRectanglesRequest { request, error in | |
self.completedVisionRequest(request, error: error) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func completedVisionRequest(_ request: VNRequest?, error: Error?) { | |
// Only proceed if a rectangular image was detected. | |
guard let rectangles = request?.results as? [VNRectangleObservation] else { | |
guard let error = error else { return } | |
print("Error: Rectangle detection failed - Vision request returned an error. \(error.localizedDescription)") | |
return | |
} | |
// do stuff with your rectangles | |
for rectangle in rectangles { | |
print(rectangle.boundingBox) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | Type | Range | Default | |
---|---|---|---|---|
.maximumObservations | Int | [0...] | 1 | |
.minimumAspectRatio | Float | [0.0...1.0] | 0.5 | |
.maximumAspectRatio | Float | [0.0...1.0] | 0.5 | |
.minimumSize | Float | [0.0...1.0] | 0.2 | |
.quadratureTolerance | Float | [0.0...45.0] | 30.0 | |
.minimumConfidence | Float | [0.0...1.0] | 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) | |
self.view.addGestureRecognizer(tapGesture) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct FormViewFix1: View { | |
@State var name = "" | |
@State var yearsExpereince: Int = 0 | |
var body: some View { | |
NavigationView { | |
Form { | |
Section(header: Text("Applicant Info"), content: { | |
HStack { | |
Text("Name:") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(UIKit) | |
extension View { | |
func hideKeyboard() { | |
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) | |
} | |
} | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
VStack { | |
TextView("", $myText) | |
} | |
.onTapGesture { | |
self.dismissKeyboard() | |
} | |
... |
OlderNewer