我研究了很多关于人脸检测的例子,我还使用 CIDetector
和 HaarCascade_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.
}
关于ios - 如何在 iPhone 中检测眼睛瞳孔并测量瞳孔之间的距离,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12314180/