使用OpenCV和LBP在iPhone上进行人脸检测 [英] Face Detection on iPhone using OpenCV and LBP

查看:215
本文介绍了使用OpenCV和LBP在iPhone上进行人脸检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功使用OpenCV-2.1.0中的Haar算法(cvHaarDetectObjects)来检测iOS 4.2的Objective-C项目中的图片和视频帧中的面部。但是,在大多数情况下,iPhone 4上的视频帧处理时间大约需要1-2秒。我正在使用的代码示例如下:

I have been successfully working with the Haar algorithm in OpenCV-2.1.0 (cvHaarDetectObjects) to detect faces in pictures and video frames from within an Objective-C project for iOS 4.2. However, the processing time for the video frames still takes about 1-2 seconds on the iPhone 4 under most conditions. An example of the code I am using is given below:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"haarcascade_frontalface_alt" ofType:@"xml"];

    CvHaarClassifierCascade* cascade = 
            (CvHaarClassifierCascade*)cvLoad([path cStringUsingEncoding:NSASCIIStringEncoding], 
                                             NULL, NULL, NULL);
    CvMemStorage* storage = cvCreateMemStorage(0);

    CvSeq* faces = cvHaarDetectObjects(small_image, cascade, storage, 1.2, 0, 
                                       0 |CV_HAAR_DO_ROUGH_SEARCH |CV_HAAR_FIND_BIGGEST_OBJECT, cvSize(30, 30));

我尝试了多种优化技术,包括ROI的智能应用,以及使用整数而不是浮点数。然而,这些变化花费了大量时间并且只有很小的好处。

I have tried multiple optimization techniques, including smart application of ROI, and the use of integers rather than floats. Yet these changes have taken vast amounts of time and had only a minor benefit.

有人建议我使用LBP可以大大减少面部检测时间。我一直在尝试和寻找实施LBP的方法,但无济于事。在opencv中,有一个级联文件(lbpcascade_frontalface.xml),但我找不到任何有关如何使用它的建议。

It has been suggested to me that utilisation of LBP could significantly reduce the face detection time. I have been experimenting with and searching for ways to implement LBP, but to no avail. In opencv, there is a cascade file (lbpcascade_frontalface.xml), yet I cannot find any suggestions for how to use it.

我们将不胜感激任何帮助,包括我在搜索时可能遗漏的其他优化技巧和Google链接。只要合理有效,检测的准确性并不重要。

Any help would be appreciated, including other optimization techniques and Google links that I may have missed in my searching. Accuracy of detection is not critical so long as it is reasonably effective.

谢谢!

推荐答案

尝试使用乐器确定应用程序中性能瓶颈的位置。它们可能与您认为的不同。

Try using Instruments to determine where the performance bottlenecks are in your application. Chances are they are different from what you think they might be.

另外,请查看效果指南。

Also, check out this performance guide.

这篇关于使用OpenCV和LBP在iPhone上进行人脸检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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