문제

I am using a vector of opencv Rect objects. What i want is to erase some of vectors elements inside a for-loop. However, it seems that I haven't access to vector's erase() fucntion. I am receiving the following message:

/home/christosh/Desktop/recognition-build-desktop-Qt_4_8_1_in_PATH_System_Release/../faceRec/src/Detection.cpp:88: error: 'class cv::Rect_' has no member named 'erase'

My code :

     vector<Rect> faces, eyes;
     for(int l=0; l<eyes.size(); l++){
        if(eyes[l].y> faces[i].height){
            eyes[l].erase;
        }
     }
도움이 되었습니까?

해결책

Did you miss parenthesis? That's a function.

eyes[l].erase();

Edit: Seems I misread you question. If is is stl::vector erase then you can take hint from code below: You will have to use iterator.

vector<int>::iterator it = res.begin();
for( ; it != res.end(); it++)
{
    it = res.erase(it);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top