I'm trying to detect faces on the webcam feed with Vision API. The CPU usage is very high, like 60% or 80%. Is there any way to reduce it?
I've tried receding the frames per second which I pass from the webcam feed. However that didn't help. Here's how I am trying to detect faces. This has to be updated in real time.
try? VNSequenceRequestHandler().perform([VNDetectFaceRectanglesRequest()], on: image)
if let results = VNDetectFaceRectanglesRequest().results as? [VNFaceObservation] {
DispatchQueue.main.async {
// update UI
}
}