本文介绍了如何在iPhone中检测眼睛瞳孔和测量瞳孔之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我研究过很多关于人脸检测的例子,而且我已经使用 CIDetector
和 HaarCascade_eye.xml $检测到iPhone的眼睛C $ C>。但我想检测眼睛的瞳孔并想测量瞳孔之间的距离。请指导我,以便我能做到。
I have studied a lot of example about face detection and also I have detected the eye in iPhone using CIDetector
and HaarCascade_eye.xml
. But I want to detect the pupils of eye and want to measure the distance between pupils. Please guide me something so that I could do that.
推荐答案
使用以下公式计算两点之间的距离:
To calculate distance between two points using the following formula:
这将获得两只眼睛的中心点(由CIDetector检测并比较它们的位置以输出您正在寻找的测量值。
This will get center points of the two eyes (as detected by CIDetector) and compare their locations to output the measurements you're 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.
}
这篇关于如何在iPhone中检测眼睛瞳孔和测量瞳孔之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!