Comments (2)
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.
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:
It should demonstrate how to achieve what you want. Good luck!
from mlkit.
Related Issues (20)
- [Feature request] Text Recognition Cyrillic Support
- [feature request] Docs scanner ml kit version compellability HOT 1
- [Bug report] Zeros are dropped in barcodes HOT 1
- Mlkit
- Please delete this
- [Feature request] Add Labels Feature for Document Type Guidance on ML Kit Document Scanner Interface
- Selfie Segmentation confidence threshold
- mlkit:text-recognition-chinese Not working properly HOT 3
- [Bug report] DigitalInk: No implementation found DigitalInkRecognizerJni.initNativeRecognizer HOT 1
- [Feature Request] Support for Simulators on M1 Apple Silicon / arm64 architecture HOT 2
- [Feature request] Title for the request
- Add thai language.
- [Bug report] "MeHeeman" HOT 1
- Pose Detection: InFrameConfidence values
- [Feature request] Add output QR Code corners according to static ordering via an option
- [Feature request] Modularization Enhancement for Document Scanner API Library
- [Bug report] Inconsistent scanning of dense QR codes?
- [Bug report] Title for the bug HOT 1
- How to get compressed pdf in output
- [Feature request] Swift Package Manager support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlkit.