Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my haar classifier slow?
    primarykey
    data
    text
    <p>I trained a HAAR classifier to detect hands in a LIVE VIDEO FEED from the webcam. I used 621 positives &amp; 3712 negatives.</p> <p>I used opencv_createsamples to generate the vec file for positives: ./opencv_createsamples -vec /Users/.../positivesvec.vec -info /Users/.../positiveDesc.txt -w 20 -h 30</p> <p>And then, I used opencv_traincascade to train the classifier: opencv_traincascade -data /Users/.../hand -vec /Users/.../positivesvec.vec -bg /Users/.../negativeDesc.txt -numPos 621 -numNeg 3712 -numStages 15 minHitRate 0.999 maxFalseAlarmRate 0.5 -w 20 -h 30 -mode ALL</p> <p>The training took around 30 hours or so and I got an xml file. However, when I use that xml file for detection, it is really VERY slow (1 frame in 3-4 seconds maybe).</p> <p>I know that my object detection code is correct because it works perfectly for faces. This is what I use:</p> <pre><code>trained_cascade_name = "/Users/.../cascade.xml"; if( !cascade.load( trained_cascade_name ) ){ qDebug()&lt;&lt;"Error loading cascade file!"; return; }; std::vector&lt;Rect&gt; hands; Mat frame_gray; // Haar works on grayscale images cvtColor(frame, frame_gray, CV_RGB2GRAY); equalizeHist(frame_gray, frame_gray); cascade.detectMultiScale( frame_gray, hands, 1.1, 3, 0|CV_HAAR_DO_CANNY_PRUNING|CV_HAAR_FIND_BIGGEST_OBJECT, cv::Size(30,30),cv::Size(100,100)); CvPoint topleft, bottomright; for( int i = 0; i &lt; hands.size(); i++ ) { topleft.x=hands[i].x; topleft.y=hands[i].y; bottomright.x=hands[i].x+hands[i].width; bottomright.y=hands[i].y+hands[i].height; cv::rectangle(frame, topleft, bottomright, Scalar(255,0,255), 1, 8, 0); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload