CoreML: Real Time Camera Object Detection with Machine Learning – Swift 4

Learn how to put together a Real Time Object Detection app by using one of the newest libraries announced in this year’s WWDC event. The combination of CPU and GPU allows for maximum efficiency in using inference technology from Machine Learning which enables us to create today’s application.

SqueezeNet and Resnet50 models can downloaded near the bottom at:

More detailed lessons on Showing the Camera:

Instagram Firebase Course

Facebook Group

iOS Basic Training Course

Completed Source Code

Follow me on Twitter:

30 comments

  1. Андрій Близнюк says:

    Hi, you can make tutorial for how connect sockets by STOMP protocol, or simple socket, i can’t found info about this in internet but i must communicate with server on sockets, i can’t subscribe to some topic on the java server, please help)))

  2. Андрій Близнюк says:

    And actually how communicate ios client and server? Through sockets or other technology, firebase, etc…?

  3. Mohammad Tahir says:

    how to detect fingure radius and put on the ring in fingure and also is it fingure or not.

  4. Gavin Bryan says:

    Thanks Brian, great video, really well explained as you always do. I bought your Instagram Course a few weeks back and has been fantastic working through it, I have learnt loads from it and it has accelerated my Swift / iOS knowledge. If you do any more paid or build up any paid subscription model for any future courses/material like the Instagram one, I wouldn’t hesitate to sign up. I have learnt so much from your tutorials. You’re one of the best technical tutors I’ve come across, real world examples, real code all delivered in a logical and methodical way. P.S. For anyone reading this, I have no affiliations for saying the above in anyway but as a seasoned developer and having created/delivered small amounts of training material in the past have massive respect for the amount of work that goes into creating this sort of high quality content that you would normally have to pay for. So just a massive thank you.

  5. 3RD World says:

    Hey, what is the best laptop for programming that will not lag and will maximize the range of applications you can create?

  6. Jesus Bernal says:

    what should I know before I jump into app building? or do you recommend jumping straight into app building and learn the basics on the way?

  7. jijo james says:

    Hi Brian voong sir your viedo was super .I like to ask a question ,is CS is a dead end job? Because as old as we are illness increase such as low memory power etc .How to avoid this it maybe stupid but I like to study cs and what stopping is thinking like this .What to I do? Pls reply or make video about it pls

  8. myVictor lee says:

    Thanks Brian! awesome video and terribly exciting trying it out on the iOS11 device! Just curious, how do I set the autolayout constraints for the previewLayer so that the camera switches nicely even in landscape mode. It isn’t a CALayer so I’m not aware of how to set the constraints for such type of layers. thanks 🙂

  9. myVictor lee says:

    Hi Brian,
    I tried this. But still can’t get the previewLayer orientation to change. Any ideas? thanks 🙂

    func updatePreviewLayer(layer: AVCaptureConnection, orientation: AVCaptureVideoOrientation) {
    layer.videoOrientation = orientation
    }

    let previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
    view.layer.addSublayer(previewLayer)

    // Add Frame
    previewLayer.frame = self.view.bounds
    previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill

    if let connection = previewLayer.connection {
    let currentDevice: UIDevice = UIDevice.current
    let orientation: UIDeviceOrientation = currentDevice.orientation
    let previewLayerConnection: AVCaptureConnection = connection
    if previewLayerConnection.isVideoOrientationSupported {
    switch (orientation) {
    case .portrait: updatePreviewLayer(layer: previewLayerConnection, orientation: .portrait)
    case .portraitUpsideDown: updatePreviewLayer(layer: previewLayerConnection, orientation: .portraitUpsideDown)
    case .landscapeLeft: updatePreviewLayer(layer: previewLayerConnection, orientation: .landscapeLeft)
    case .landscapeRight: updatePreviewLayer(layer: previewLayerConnection, orientation: .landscapeRight)
    default: updatePreviewLayer(layer: previewLayerConnection, orientation: .portrait)
    break
    }
    }
    }

  10. krutomjer says:

    Great tutorial Brian, I’d love a more advanced tutorials like this. I’d even buy it.

  11. Oluwatobi Omotayo says:

    Nice one Brian. I want to ask, aren’t the models going to drastically increase the size of our app binary. I mean what’s the point of CoreML if we would have to always import large models into our projects especially for simple non-game apps. One should just work with a model provided in a cloud, isn’t it to maintain the size of our apps? At least I know of apps that have Machine Learning features in them even before the release of this CoreML. What do you think Brian?

  12. Hardeep Singh says:

    I must say lots of thank you as I have learned so much from you. I wonder if I could work with you and learn a lot of things from you.
    Thank You Again 🙂

  13. Marco Zanirato says:

    Thanks Brian, great tutorial. I tried to add a label to show in screen the observations but I get this error “UILabel.setText(_:) must be called from main thread only” … Can you help, please? Thanks

  14. Mahmudul Hasan Sujan says:

    Is it possible to detect and recognize 3D object from real time camera input using ARKit ?suppose i have a car infront of device camera,i want to detect and recognize its parts from any position. will it can be done using ARkit ? Please help me.thanks in advance.or can i use CoreML for this issues ?

  15. Aleksandar Jovanov says:

    can you give example for “augmented reality” with pictures instead of barcodes ?

  16. Eli Tzar says:

    Hello Brian! I have been building an app going from the demo you made in this video, but I just updated to Xcode 9 beta 4 and it seem the app is now broken, it doesn’t recognize the mlmodels anymore, could you please look into it if you get a chance? Thanks!

  17. SirTea says:

    Hey thank you for your great tutorials! 🙂 Could you do a tutorial about using CoreML for text recognition? That would make me super happy

  18. Максим Грозный says:

    Hello Brian! Can you help me, I have an “Use of unresolved identifier ‘Resnet50′” error… That is why nothing work…

  19. Michael Roloff says:

    having an issue where it says unresolved identifier .

    let model = try VNCoreMLModel(for: SqueezeNet().model )

Comments are closed.