gpt4 book ai didi

iphone - 如何在 iOS 上识别人脸中的嘴巴和 dentry ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:59:54 25 4
gpt4 key购买 nike

我知道 iOS 5.0 上的 Core Image supports facial detection ( another example of this ),它给出了面部的整体位置,以及面部内眼睛和嘴巴的位置。

但是,我想细化这个位置以检测嘴巴和 dentry 在其中的位置。我的目标是将护齿器放在用户的嘴巴和 dentry 上。

有没有办法在 iOS 上完成此操作?

最佳答案

我指出了 my blog该教程有问题。

部分 5) Adjust For The Coordinate System:说您需要更改窗口和图像的坐标,但您不应该这样做。你不应该改变你的 View /窗口(在 UIKit 坐标中)来匹配教程中的 CoreImage 坐标,你应该做相反的事情。

这是与此相关的代码部分:
(您可以从 my blog post 或直接从 here 获得完整的示例代码。它也包含这个和其他使用 CIFilters 的示例 :D )

// Create the image and detector
CIImage *image = [CIImage imageWithCGImage:imageView.image.CGImage];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
context:...
options:...];

// CoreImage coordinate system origin is at the bottom left corner and UIKit's
// is at the top left corner. So we need to translate features positions before
// drawing them to screen. In order to do so we make an affine transform
CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
transform = CGAffineTransformTranslate(transform,
0, -imageView.bounds.size.height);

// Get features from the image
NSArray *features = [detector featuresInImage:image];
for(CIFaceFeature* faceFeature in features) {

// Get the face rect: Convert CoreImage to UIKit coordinates
const CGRect faceRect = CGRectApplyAffineTransform(
faceFeature.bounds, transform);

// create a UIView using the bounds of the face
UIView *faceView = [[UIView alloc] initWithFrame:faceRect];

...

if(faceFeature.hasMouthPosition) {
// Get the mouth position translated to imageView UIKit coordinates
const CGPoint mouthPos = CGPointApplyAffineTransform(
faceFeature.mouthPosition, transform);
...
}
}

一旦你得到嘴的位置(mouthPos),你只需将你的东西放在它上面或附近。

这个一定的距离可以通过实验计算出来,而且一定是相对于眼睛和嘴巴形成的三角形而言的。如果可能的话,我会用很多面孔来计算这个距离(推特头像?)

希望对您有所帮助:)

关于iphone - 如何在 iOS 上识别人脸中的嘴巴和 dentry ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9924345/

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