Monday 15 June 2015

c++ - Using opencv + viola jones running slow -



c++ - Using opencv + viola jones running slow -

i trying implement face detection viola jones classifier using opencv cascade. code using:

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; // observe 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 detected faces for( int = 0; < 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); homecoming 0; }

the problem says viola jones implementation in opencv , takes 30fps run (from author side) taking 6 seconds run normal hd image face detection of around 1920x1080. wanted inquire implementation right or there problem way implementing method , there way can create faster ? cascade.xml file trained using sample images. give thanks you.

c++ opencv cascade haar-classifier viola-jones

No comments:

Post a Comment