面向过滤器实现,如MSQRD / SnapChat [英] Face filter implementation like MSQRD/SnapChat

查看:176
本文介绍了面向过滤器实现,如MSQRD / SnapChat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将现场面部过滤器开发为MSQRD / Snapchat实时过滤器,但是如果我使用增强现实框架并检测面部或使用核心图像来检测面部和相应处理,我无法知道如何继续。如果有人知道如何实现它,请告诉我吗?

I want to develop the live face filters as MSQRD/Snapchat live filters but did not able to find out how should I proceed should I use Augmented Reality framework and detect face OR use core image to detect the face and process accordingly. Please let me know if anyone has the idea how to implement the same?

推荐答案

我建议你去核心图像 CIDetector https://developer.apple.com/library/ios/documentation/ GraphicsImaging / Conceptual / CoreImaging / ci_detect_faces / ci_detect_faces.html 从iOS 5开始提供它,它有很好的文档。

I would recommend going with Core Image and CIDetector. https://developer.apple.com/library/ios/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_detect_faces/ci_detect_faces.html It has been available since iOS 5 and it has great documentation.

创建面部检测器示例:

CIContext *context = [CIContext contextWithOptions:nil];                    // 1
NSDictionary *opts = @{ CIDetectorAccuracy : CIDetectorAccuracyHigh };      // 2
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:context
                                          options:opts];                    // 3

opts = @{ CIDetectorImageOrientation :
          [[myImage properties] valueForKey:kCGImagePropertyOrientation] }; // 4
NSArray *features = [detector featuresInImage:myImage options:opts];        // 5

以下是代码的作用:

1.-创建一个上下文;在这个例子中,iOS的上下文。您可以使用处理图像中描述的任何上下文创建功能。)您还可以选择在创建检测器时提供nil而不是上下文。)

1.- Creates a context; in this example, a context for iOS. You can use any of the context-creation functions described in Processing Images.) You also have the option of supplying nil instead of a context when you create the detector.)

2.-创建选项字典以指定检测器的准确度。您可以指定低精度或高精度。精度低(CIDetectorAccuracyLow)快;此示例中显示的高精度是彻底但较慢的。

2.- Creates an options dictionary to specify accuracy for the detector. You can specify low or high accuracy. Low accuracy (CIDetectorAccuracyLow) is fast; high accuracy, shown in this example, is thorough but slower.

3.-为面创建检测器。您可以创建的唯一类型的检测器是人脸检测器。

3.- Creates a detector for faces. The only type of detector you can create is one for human faces.

4.-设置用于查找面部的选项字典。让Core Image了解图像方向非常重要,这样探测器才能知道它可以在哪里找到直立面。大多数情况下,您将从图像本身读取图像方向,然后将该值提供给选项字典。

4.- Sets up an options dictionary for finding faces. It’s important to let Core Image know the image orientation so the detector knows where it can find upright faces. Most of the time you’ll read the image orientation from the image itself, and then provide that value to the options dictionary.

5.-使用检测器查找功能在图像中。您提供的图像必须是CIImage对象。 Core Image返回一个CIFeature对象数组,每个对象代表图像中的一个面。

5.- Uses the detector to find features in an image. The image you provide must be a CIImage object. Core Image returns an array of CIFeature objects, each of which represents a face in the image.

这里有一些打开的项目可以帮助你开始 CoreImage 或其他技术 GPUImage OpenCV

Here some open projects that could help you out to start with CoreImage or other technologies as GPUImage or OpenCV

1 https://github.com/aaronabentheuer/AAFaceDetection ( CIDetector - Swift)

1 https://github.com/aaronabentheuer/AAFaceDetection (CIDetector - Swift)

2 https:// github .com / BradLarson / GPUImage (Objective-C)

2 https://github.com/BradLarson/GPUImage (Objective-C)

3 https://github.com/jeroentrappers/FaceDetectionPOC (Objective-C:它已经弃用了iOS9的代码)

3 https://github.com/jeroentrappers/FaceDetectionPOC (Objective-C: it has deprecated code for iOS9)

4 https://github.com/kairosinc/Kairos-SDK-iOS (目标 - C)

5 https://github.com/macmade/FaceDetect (OpenCV)

这篇关于面向过滤器实现,如MSQRD / SnapChat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆