質問

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