您应该查看http://libccv.org/
这是相当新的东西,但是它提供了免费的开源高级API来进行人脸检测。
(...我敢说,真是太不可思议了)
编辑:还值得注意的是,这是不依赖opencv的少数几个库之一,仅用于踢球,这是文档页面上用于人脸检测的代码副本,可让您大致了解所涉及的内容:
#include <ccv.h>
int main(int argc, char** argv)
{
ccv_dense_matrix_t* image = 0;
ccv_read(argv[1], &image, CCV_IO_GRAY | CCV_IO_ANY_FILE);
ccv_bbf_classifier_cascade_t* cascade = ccv_load_bbf_classifier_cascade(argv[2]); ccv_bbf_params_t params = { .interval = 8, .min_neighbors = 2, .accurate = 1, .flags = 0, .size = ccv_size(24, 24) };
ccv_array_t* faces = ccv_bbf_detect_objects(image, &cascade, 1, params);
int i;
for (i = 0; i < faces->rnum; i++)
{
ccv_comp_t* face = (ccv_comp_t*)ccv_array_get(faces, i);
printf("%d %d %d %d\n", face->rect.x, face->rect.y, face->rect.width, face->rect.y);
}
ccv_array_free(faces);
ccv_bbf_classifier_cascade_free(cascade);
ccv_matrix_free(image);
return 0;
}