text: CascadeClassifier.detectMultiScale takes a minute! Why?
  I am trying to create a vertebra detector. After manually creating a small set of training and background images, trained a classifier, and am now trying to use it. Results are nonsense, but that I expected. The problem I am having is very long running time ~ 1 minute for one image, instead of some ~ 100ms, for release build.
  What am I doing wrong?
  detection time = 65799.5 ms
  #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <opencv2/highgui/highgui.hpp> using namespace cv; int main(int argc, char* argv[]) { CascadeClassifier cascade; cascade.load("cascade.xml"); cv::Mat img = cv::imread("D:/img.png",0); int i = 0; double t = 0; double xres=0.625, yres=0.625; vector<Rect> faces; equalizeHist(img, img); t = (double)cvGetTickCount(); cascade.detectMultiScale( img, faces, 1.1, 2, 0, Size(10/xres, 10/yres), Size(55/xres, 55/yres) ); //min 10mm, max 55mm t = (double)cvGetTickCount() - t; printf( "detection time = %g ms\n", t/((double)cvGetTickFrequency()*1000.) ); for( vector<Rect>::const_iterator r = faces.begin(); r != faces.end(); r++, i++ ) { Point center; Scalar color = CV_RGB(255,255,255); int radius; center.x = cvRound((r->x + r->width*0.5)); center.y = cvRound((r->y + r->height*0.5)); radius = cvRound((r->width + r->height)*0.25); circle( img, center, radius, color, 3, 8, 0 ); } cv::imshow( "result", img ); cv::waitKey(0); return 0; }
  It is possible that a too high res could slow the detector. Your image is in which resolution? Also try to increase the number of neighbors. Anyway, the cascade training maybe a bit unpredictable, it does not guarantees a good detector in all the situations.
  Image resolution is 512x512. Increasing the number of neighbors to 4 changes nearly nothing. Number of detections is about the same, and execution time is the same.