Last active
August 21, 2018 20:51
-
-
Save brunomunizaf/346dcc01a5520b14a5ae61f7aec13d45 to your computer and use it in GitHub Desktop.
Heartbeat AR/ML middle
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
// MARK: - Lifecycle | |
extension ViewController { | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
setupAR() | |
setupML() | |
loopCoreMLUpdate() | |
} | |
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) | |
sceneView.session.pause() | |
} | |
} | |
// MARK: - Setup | |
extension ViewController { | |
private func setupAR() { | |
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapped)) | |
sceneView.addGestureRecognizer(tapGestureRecognizer) | |
let configuration = ARWorldTrackingConfiguration() | |
sceneView.session.run(configuration) | |
} | |
private func setupML() { | |
guard let selectedModel = try? VNCoreMLModel(for: example_5s0_hand_model().model) else { | |
fatalError("Could not load model.") | |
} | |
let classificationRequest = VNCoreMLRequest(model: selectedModel, | |
completionHandler: classificationCompleteHandler) | |
visionRequests = [classificationRequest] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment