accessing elements in vector of vector of points

asked 2016-03-09 01:01:54 -0600

GANESH PRASAATH L gravatar image

updated 2016-03-09 01:19:47 -0600

berak gravatar image

I tried people counting using HOG descriptor. When the program is compiled, the last part of the program for people counting shows errors.

  HOGDescriptor hog;
    hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
    namedWindow("people detector", 1);
    int required,incoming,outgoing;
  required=0;
  incoming=0;
   outgoing=0;
    for(;;)
    {
        vector<Rect> found, found_filtered;
        double t = (double)getTickCount();
        hog.detectMultiScale(img, found, 0, Size(8,8), Size(32,32), 1.05, 2);
        t = (double)getTickCount() - t;
        printf("tdetection time = %gms\n", t*1000./cv::getTickFrequency());
        size_t i, j;
        for( i = 0; i < found.size(); i++ )
        {
            Rect r = found[i];
            for( j = 0; j < found.size(); j++ )
                if( j != i && (r & found[j]) == r)
                    break;
            if( j == found.size() )
                found_filtered.push_back(r);
        }
Point pt,ptretrieve;

vector<vector<Point>>rectcount;
for(i=0;i<found_filtered.size();i++)
{
Rect r = found_filtered[i];
pt.x=r.tl().x+(r.br().x-r.tl().x)/2;
pt.y=r.tl().y+(r.br().y-r.tl().y)/2;
for(ii=0;ii<found_filtered.size();ii++)
{
ptretrieve=rectcount[ii].back;
if(pt.x-ptretrieve.x<=3&&pt.y-ptretrieve.y<=3)
{
required=ii;
break;
}
}
ptretrieve=rectcount[required].back;
if(pt.x==150&&ptretrieve.x==151)
incoming++;
if(pt.x==150&&ptretrieve.x==149)
ougoing++;
rectcount[required].push_back(pt);
}
edit retag flag offensive close merge delete

Comments

please reply what is wrong because the last 6 lines show error

GANESH PRASAATH L gravatar imageGANESH PRASAATH L ( 2016-03-09 02:27:01 -0600 )edit
2
  • sloppiness, typos, missing indentation, whatnot
  • you still don't know, how to use std::vector, please go again here
  • then, there's a wrong assumption, that rectcount.size() == found_filtered.size() the first time you access it.
berak gravatar imageberak ( 2016-03-09 02:59:47 -0600 )edit