你应该看看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;
}