C++ 使用opencv+;维奥拉·琼斯跑得很慢

C++ 使用opencv+;维奥拉·琼斯跑得很慢,c++,opencv,cascade,haar-classifier,viola-jones,C++,Opencv,Cascade,Haar Classifier,Viola Jones,我正在尝试使用opencv级联实现人脸检测viola-jones分类器。这是我正在使用的代码: int main( ){ SYSTEMTIME tm; GetLocalTime(&tm); printf("Date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wDay, tm.wMonth, tm.wYear, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds); //CString t = C

我正在尝试使用opencv级联实现人脸检测viola-jones分类器。这是我正在使用的代码:

int main( ){
SYSTEMTIME tm;

GetLocalTime(&tm);
printf("Date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wDay, tm.wMonth, tm.wYear, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
//CString t = CTime::GetCurrentTime().Format("%H:%M:%S:%MS");
Mat image;
Mat frame_gray;

image = imread("test.jpg", CV_LOAD_IMAGE_COLOR); 
namedWindow( "window1", 1 );   imshow( "window1", image );


// Load Face cascade (.xml file)
CascadeClassifier face_cascade;
face_cascade.load( "cascades.xml" );



cvtColor( image, frame_gray, CV_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );


GetLocalTime(&tm);
printf("Date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wDay, tm.wMonth, tm.wYear, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
float pyramidScale = 1.5f;
// Detect faces
std::vector<Rect> faces;
face_cascade.detectMultiScale( frame_gray, faces, pyramidScale, 3, 0, Size(20, 20), Size(50, 50));

GetLocalTime(&tm);
printf("Date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wDay, tm.wMonth, tm.wYear, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);

// Draw circles on the detected faces
for( int 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( image, center, Size( faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar( 255, 255, 255 ), 4, 8, 0 );
}

imshow( "Detected Face", image );


SYSTEMTIME tm1;
GetLocalTime(&tm);
printf("Date: %02d.%02d.%d, %02d:%02d:%02d:%02d\n", tm.wDay, tm.wMonth, tm.wYear, tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds);
//cout<< "Time : "<<tm.wHour<<":"<<tm.wMinute << ":"<< tm.wSecond << ":" << tm.wMilliseconds << "\n";
waitKey(0);                  
return 0;
}
int main(){
SYSTEMTIME tm;
GetLocalTime&tm;
printf(“日期:%02d.%02d.%d,%02d:%02d:%02d\n”,tm.wDay,tm.wMonth,tm.wYear,tm.wHour,tm.wMinute,tm.wssecond,tm.wmillisonds);
//CString t=CTime::GetCurrentTime().格式(“%H:%M:%S:%MS”);
Mat图像;
垫子框架为灰色;
image=imread(“test.jpg”,CV\u LOAD\u image\u COLOR);
namedWindow(“窗口1”,1);imshow(“窗口1”,图像);
//加载面级联(.xml文件)
层叠式分级机;
face_cascade.load(“cascades.xml”);
CVT颜色(图像、帧灰、CV灰);
均衡器历史(帧灰,帧灰);
GetLocalTime&tm;
printf(“日期:%02d.%02d.%d,%02d:%02d:%02d\n”,tm.wDay,tm.wMonth,tm.wYear,tm.wHour,tm.wMinute,tm.wssecond,tm.wmillisonds);
浮标度=1.5f;
//检测人脸
向量面;
检测多尺度(帧灰度,面,金字塔尺度,3,0,大小(20,20),大小(50,50));
GetLocalTime&tm;
printf(“日期:%02d.%02d.%d,%02d:%02d:%02d\n”,tm.wDay,tm.wMonth,tm.wYear,tm.wHour,tm.wMinute,tm.wssecond,tm.wmillisonds);
//在检测到的面上绘制圆
对于(int i=0;i//你能在高清图像中寻找20到50像素大小的人脸吗?嗯,是的,这需要很长时间…你的图像越乱,速度就越快。另外,试试lbpcascades,它们的精度稍低,但速度更快!是的,高清图像是我使用的样本图像集,它是从高点倾斜拍摄的街道。我会e lbpcades a shot thankshmm,如果你的相机从灯柱上向下拍摄,你将无法再看到真实的人的“正面”视图。嗨,基本上,相机可以看到人的正面和侧面视图,但当他们穿过街道时,相机与街道垂直,所以也可以看到侧面和背面视图。