gpt4 book ai didi

ios - 如何在 iPhone 中检测眼睛瞳孔并测量瞳孔之间的距离

转载 作者:可可西里 更新时间:2023-11-01 05:41:57 25 4
gpt4 key购买 nike

我研究了很多关于人脸检测的例子,我还使用 CIDetectorHaarCascade_eye.xml 检测了 iPhone 中的眼睛。但是我想检测眼睛的瞳孔并想测量瞳孔之间的距离。请指导我一些事情,以便我可以做到这一点。

最佳答案

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

这将获得两只眼睛的中心点(由 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com