GithubHelp home page GithubHelp logo

Comments (2)

bishalg avatar bishalg commented on May 21, 2024

I was able to make the code work without crashing by removing the delegate call which was on Main Thread. This was not the desired as that was the only workaround that worked for me.

For example, I have tried following style to cal the VisionFace detector on a background thread as following -

let dict: NSDictionary = [
      "imageWidth": imageWidth,
      "imageHeight": imageHeight,
      "visionImage": visionImage
    ]
    if Thread.isMainThread {
      self.performSelector(inBackground: #selector(detectFace(info:)), with: dict)
    } else {
      self.detectFacesOnDevice(in: visionImage, width: imageWidth, height: imageHeight)
    }

And then the method -

 @objc func detectFace(info: NSDictionary) {
    if let imageWidth = info["imageWidth"] as? CGFloat,
      let imageHeight = info["imageHeight"] as? CGFloat,
      let visionImage = info["visionImage"] as? VisionImage {
      self.detectFacesOnDevice(in: visionImage, width: imageWidth, height: imageHeight)
    }
  }

Even if it works well for most cases. There are cases when it doesn't work and crash on -
detectedFaces = try faceDetector.results(in: image).

For example -

    let options = VisionFaceDetectorOptions()
    //options.landmarkMode = .all
    //options.classificationMode = .all
    //options.contourMode = .all
    options.performanceMode = .accurate

Only

Performance Mode = .accurate

seems to work, other options will again trigger a crash, as the recording, affected by other Option flags.

from mlkit.

bcdj avatar bcdj commented on May 21, 2024

The Face detection in Firebase is deprecated. ML Kit (including face detection API) has migrated out of Firebase and become a standalone SDK. Please check out our quickstart sample app on how to hook up the face detector to a streaming video camera callback:

https://github.com/googlesamples/mlkit/blob/master/ios/quickstarts/vision/VisionExample/CameraViewController.swift#L175

It should demonstrate how to achieve what you want. Good luck!

from mlkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.