How to detect eye pupils and measure the distance between students on the iPhone

I have studied many examples of face detection, and have also detected an eye on an iPhone using CIDetector and HaarCascade_eye.xml . But I want to find the pupils of the eye and I want to measure the distance between the students. Please send me something so that I can do it.

+4
source share
1 answer

To calculate the distance between two points using the following formula: distance formula

This will allow you to obtain the center points of the two eyes (as detected by the CIDetector) and compare their locations to display the results you are looking for.

 if(faceFeature.hasLeftEyePosition && faceFeature.hasRightEyePosition) { CGPoint leftEyeCenter = faceFeature.leftEyePosition; CGPoint rightEyeCenter = faceFeature.rightEyePosition; float simpleDistance = rightEyeCenter.x - leftEyeCenter.x; //This finds the distance simply by comparing the x coordinates of the two pupils float complexDistance = fabsf(sqrtf(powf(leftEyeCenter.y - rightEyeCenter.y, 2) + powf(rightEyeCenter.x - leftEyeCenter.x, 2))); //This will return the diagonal distance between the two pupils allowing for greater distance if the pupils are not perfectly level. } 
+4
source

Source: https://habr.com/ru/post/1432894/


All Articles