Skip to content

Instantly share code, notes, and snippets.

View brettfazio's full-sized avatar
🐢
<- Turtle

Brett Fazio brettfazio

🐢
<- Turtle
View GitHub Profile
@State var action: Bool = false
struct OpeningView : View {
@State var action: Bool = false
var body: some View {
NavigationView {
HStack {
NavigationLink(destination: NewView(), isActive: $action) {
EmptyView()
}
let model = try VNCoreMLModel(for: CatDogClassifier().model)
let request = VNCoreMLRequest(model: model) { (request, error) in
self.processClassifications(for: request, error: error)
}
func processClassifications(for request: VNRequest, error: Error?) {
DispatchQueue.main.async {
guard let results = request.results else {
return
}
let classifications = results as! [VNClassificationObservation]
if classifications.first!.confidence > 0.9 {
print("> 0.9 confidence that request is a \(classifications.first!.identifier)")
}
self.imagePicker = UIImagePickerController()
// Use the camera as the source
imagePicker.source = .camera
// Need to specify the delegate to get the result
imagePicker.delegate = self
// Present the imagePicker
present(imagePicker, animated: true)
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
self.imagePicker.dismiss(animated: true)
guard let image = info[.editedImage] as? UIImage else {
print("No image found.")
return
}
// At this point we know we have an image.
// Print out the scale and size as a test:
var body: some View {
ImagePicker()
}
fun logIn(email: String, password: String) {
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, OnCompleteListener { task ->
if (task.isSuccessful) {
observer.logInSuccess(email, password)
} else {
observer.logInFailure(task.exception, email, password)
}
})
}