如何检测瞳孔并测量iPhone中瞳孔间的距离

我已经研究了很多关于人脸检测的例子,同时我也使用CIDetectorHaarCascade_eye.xml在iPhone中检测了眼睛。 但是我想检测瞳孔,想要测量瞳孔之间的距离。 请指导一下我能做到的事情。

要使用以下公式计算两点之间的距离: 距离公式

这将获得两只眼睛的中心点(由CIDetector检测到)并比较它们的位置以输出您正在查找的测量结果。

 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. } 
Interesting Posts