This file contains 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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
UIApplication.shared.keyWindow?.layer.speed = 100 | |
return true | |
} |
This file contains 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
import ARKit | |
import Vision | |
class ViewController: UIViewController { | |
@IBOutlet var sceneView: ARSCNView! | |
private let serialQueue = DispatchQueue(label: "com.hb.dispatchqueueml") | |
private var visionRequests = [VNRequest]() | |
private let webView = UIWebView(frame: CGRect(x: 0, y: 0, width: 640, height: 480)) | |
} |
This file contains 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: - Private | |
extension ViewController { | |
private func updateCoreML() { | |
let pixbuff : CVPixelBuffer? = (sceneView.session.currentFrame?.capturedImage) | |
if pixbuff == nil { return } | |
let ciImage = CIImage(cvPixelBuffer: pixbuff!) | |
let imageRequestHandler = VNImageRequestHandler(ciImage: ciImage, options: [:]) | |
do { |
This file contains 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) { |
This file contains 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: - Private | |
extension ViewController { | |
private func classificationCompleteHandler(request: VNRequest, error: Error?) { | |
if error != nil { | |
print("Error: " + (error?.localizedDescription)!) | |
return | |
} | |
guard let observations = request.results else { | |
print("No results") | |
return |
This file contains 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: - Private | |
extension ViewController { | |
@objc func tapped(recognizer: UIGestureRecognizer) { | |
guard let currentFrame = self.sceneView.session.currentFrame, | |
let url = URL(string: "https://www.supercharge.io") else { | |
return | |
} | |
webView.loadRequest(URLRequest(url: url)) |
This file contains 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
enum State { | |
case initial | |
case final | |
} | |
protocol AnimatedTransition { | |
func imageView(for transition: TransitionDelegate) -> UIImageView? | |
} |
This file contains 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 OtherViewController: UIViewController { | |
// MARK: - IBOutlets | |
@IBOutlet weak var imageView: UIImageView! | |
} | |
// MARK: - AnimatedTransition | |
extension OtherViewController: AnimatedTransition { | |
func imageView(for transition: TransitionDelegate) -> UIImageView? { | |
return imageView | |
} |
This file contains 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 imageView: UIImageView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(tappedImage)) | |
imageView.isUserInteractionEnabled = true | |
imageView.addGestureRecognizer(tapRecognizer) | |
} |
OlderNewer