2016-08-01 33 views

回答

2

很有可能,只是返回围绕您的检测到的对象的边界框的大小,你可以通过各种方式做到这一点,比如获取你围绕对象绘制的矩形的宽度和高度。另一个简单的方法是使用size

在C++中它可以是这样的:

//-- Detect faces 
    face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30)); 

    for(size_t i = 0; i < faces.size(); i++) 
    { 
    Point center(faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5); 
    ellipse(frame, center, Size(faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0); 

并在此之后,把cout << faces[i].size << endl;

完整的代码可以发现here。阅读更多关于Haar基于特征的级联分类器的对象检测here

相关问题