使用 OpenCV 和 LBP 在 iPhone 上进行人脸检测
我已经成功地使用 OpenCV-2.1.0 (cvHaarDetectObjects) 中的 Haar 算法来检测 iOS 4.2 的 Objective-C 项目中的图片和视频帧中的人脸。然而,在大多数情况下,iPhone 4 上视频帧的处理时间仍然需要大约 1-2 秒。下面给出了我正在使用的代码示例:
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 的智能应用,以及使用整数而不是浮点数。然而这些改变花费了大量的时间,而且只带来了很小的好处。
有人建议我利用 LBP 可以显着减少人脸检测时间。我一直在尝试和寻找实现LBP的方法,但没有成功。在opencv中,有一个级联文件(lbpcascade_frontalface.xml),但我找不到任何有关如何使用它的建议。
任何帮助将不胜感激,包括其他优化技术和我在搜索中可能错过的谷歌链接。检测的准确性并不重要,只要它相当有效即可。
谢谢!
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));
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.
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.
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.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 Instruments 来确定位置性能瓶颈在于您的应用程序中。它们很可能与您想象的不同。
另外,请查看此性能指导。
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.