我研究了很多关于人脸检测的例子,并且我已经使用CIDetector
和检测了 iPhone 中的眼睛HaarCascade_eye.xml
。但我想检测眼睛的瞳孔并想测量瞳孔之间的距离。请指导我一些事情,以便我可以做到这一点。
问问题
3486 次
1 回答
4
使用以下公式计算两点之间的距离:
这将获得两只眼睛的中心点(由 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.
}
于 2012-09-07T08:19:19.020 回答