Retrieving two highest values from vector
Hi people
I have declared a vector that stores an area of all Bounding Boxes in a given frame. I then used a iterated this vector from beginning to end to retrieve value. I then sorted these values in ascending order (lowest -> highest).
Here is the Code i use:
double area = contourArea(boundingBoxArea);
list_area.push_back(area);
sort(list_area.begin(), list_area.end());
vector<double>::const_iterator area_iter;
int i = 0;
for(area_iter = list_area.begin(); area_iter != list_area.end(); area_iter++)
{
i++;
cout<<"Iterator " <<i<< " size is : " <<*area_iter<<endl;
}
My issue is that I am only interested in the last two values out of the set of numbers (2 highest values) but I cant really get my head around it to how should i go about it to achieve my goal.
Anyone out here has a suggestion or solution to my problem...?
Regards