I am doing real time face recognition on a video stream.
Right now, it's a bit slow, so I decided to use the regionOfInterest
of my VNDetectFaceLandmarksRequest
to reduce the size of the image where the algorithm has to do face recognition.
The underlying idea is that the face will be always more or less in the same position within two frame; so I use the previous faceObservation result with a transform.
In this case, drift is 0.05 (meaning that we allow the face to move at most 0.05% of the size of the frame)
My calculation is the following, and the bounding box seems correct:
CGRect(x: faceObservation.boundingBox.origin.x - self.drift, y: faceObservation.boundingBox.origin.y - self.drift, width: faceObservation.boundingBox.width + self.drift, height: faceObservation.boundingBox.height + self.drift * 2)
However, I noticed that the calculation is 50% slower when I set the regionOfInterest
This doesn't make sense to me.
Is there something I do wrong, or is my assumption incorrect ?