c++ - Speed up a people detection program, written using OpenCV 3.0 -


i use opencv 3.0.0 , visual studio 2012. i've found program detect people , count them , determine direction of motion. it's slow. have idea how speed up?

#include <iostream> #include <opencv2/opencv.hpp>  using namespace std; using namespace cv;  int main (int argc, const char * argv[]) {     videocapture cap("c:/users/john/downloads/video/cam.avi");                   cap.set(cv_cap_prop_frame_width, 100);     cap.set(cv_cap_prop_frame_height, 110);         if (!cap.isopened())     return -1;      mat img;     hogdescriptor hog;     hog.setsvmdetector(hogdescriptor::getdefaultpeopledetector());      namedwindow("video capture", cv_window_autosize);     while (true)     {         cap >> img;         if (!img.data)         continue;          vector<rect> found, found_filtered;         hog.detectmultiscale(img, found, 0, size(8,8), size(32,32), 1.05, 2);          size_t i, j;         (i=0; i<found.size(); i++)         {             rect r = found[i];             (j=0; j<found.size(); j++)             if (j!=i && (r & found[j])==r)             break;             if (j==found.size())             found_filtered.push_back(r);         }         (i=0; i<found_filtered.size(); i++)         {             rect r = found_filtered[i];             r.x += cvround(r.width*0.1);             r.width = cvround(r.width*0.8);             r.y += cvround(r.height*0.06);             r.height = cvround(r.height*0.9);             rectangle(img, r.tl(), r.br(), cv::scalar(0,255,0), 2);         }         imshow("video capture", img);         if (waitkey(33) >= 0)         break;     }     return 0; } 

if there cuda gpu try gpu version of same code

according this

http://opencv.org/platforms/cuda.html

http://opencv.org/wp-content/uploads/2012/06/perf.png

8x times faster pedesterian detection

https://github.com/itseez/opencv/blob/master/samples/gpu/hog.cpp


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -