I am quiet fresh to C++ and programming in general, I am writing an OpenCv application in C++ environment.
WHAT I AM TRYING TO ACHIEVE:
OK, so I got some Rectangles center points stored in a vector, Now I am using a reverse Iterator to iterate over the vector with rectangle center points and store every 10th center point into new vector.
I then again iterate over that new vector that stores every 10th rectangle center point with normal iterator, And I want to subtract 1st element from 2nd element 3rd element from 4th element and so on, the subtraction results, I want to store into another new vector :D
It might be slightly confusing to some people; I am confused, myself, that is why below I will add the code I have written.
vector<Point> Rightarm;
vector<Point> Leftarm;
vector<Point>::reverse_iterator RightMovmentIter;
vector<Point>::reverse_iterator LeftarmMovmentIter;
vector<Point> RightTracking;
vector<Point> LeftTracking;
for(RightMovmentIter = Rightarm.rbegin(); RightMovmentIter != Rightarm.rend(); RightMovmentIter+=10)
{
RightTracking.push_back(*RightMovmentIter);
}
for(LeftarmMovmentIter = Leftarm.rbegin(); LeftarmMovmentIter != Leftarm.rend(); LeftarmMovmentIter+=10)
{
LeftTracking.push_back(*LeftarmMovmentIter);
}
vector<Point>::iterator RresultIter;
vector<Point>::iterator Leftresult_Iter;
vector<Point> summery;
for(RresultIter = RightTracking.begin(); RresultIter != RightTracking.end(); RresultIter++)
{
summery = *RresultIter - *RresultIter++;
}
PROBLEMS:
1st Problem is that when I run the program I get run time error I belief it's because at the begining of the vector Rightarm & Leftarm do not have 10 elements and when the Iterator runs through it and is trying to look for the 10th element i cant....HOW do I work this out then?
2nd Problem is to do with this line summery = *RresultIter - *RresultIter++; I know it's wrong and this is the best attempt I could of think of, but what I want to do is to subtract 1st element from 2nd element and store it in summery element...
Hopefully This describes my problem well enough for the readers Regards