|
发表于 2016-11-15 17:47:53
|
显示全部楼层
//load an image and convert it to gray (single-channel)
Mat gray = imread("lena.png", CV_LOAD_IMAGE_GRAYSCALE);
if(gray.empty())
{
fprintf(stderr, "Can not load the image file.\n");
return -1;
}
std::vector<FaceInfo> faces;
int nResult = 0;
///////////////////////////////////////////
// frontal face detection
// it's fast, but cannot detect side view faces
//////////////////////////////////////////
//!!! The input image must be a gray one (single-channel)
//!!! DO NOT RELEASE pResults !!!
nResult = facedetect_frontal(faces, (unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, (int)gray.step,
1.2f, 2, 48);
printf("%d frontal faces detected.\n", nResult);
//print the detection results
for(int i = 0; i < (int)faces.size(); i++)
{
FaceInfo fi = faces;
printf("face_rect=[%d, %d, %d, %d], neighbors=%d\n", fi.x, fi.y, fi.width, fi.height, fi.neighbors);
}
下载的例子使用的接口跟在一楼时提供的不一致,而且face得到的数据是乱码,应该是vector被破坏了,接口是不是更新的有问题?有没有使用最新版的人交流一下? |
|