Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MARK: - Lifecycle
- extension ViewController {
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- setupAR()
- setupML()
- }
- 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)
- classificationRequest.imageCropAndScaleOption = VNImageCropAndScaleOption.centerCrop
- visionRequests = [classificationRequest]
- loopCoreMLUpdate()
- }
- }
Add Comment
Please, Sign In to add comment