I am assuming from what you have written that you want to find the average displacement of all the feature points between the two frames. In that case all you have to do is compute the "hypotenuse" in a loop over the features, add up all its values, and then divide by the number of features.
Ok, here's your answer:
cvCalcOpticalFlowPyrLK(frame1_1C, frame2_1C, pyramid1, pyramid2, frame1_features, frame2_features, corner_count, optical_flow_window, 5, optical_flow_found_feature, NULL, optical_flow_termination_criteria, NULL);
//here the features that I extract them
double sumOfDistances = 0;
for(int i = 0; i < corner_count; ++i)
{
int x1 = (int) frame1_features[i].x;
int y1 = (int) frame1_features[i].y;
int x2 = (int) frame2_features[i].x;
int y2 = (int) frame2_features[i].y;
int dx = x2 - x1;
int dy = y2 - y1;
sumOfDistances += sqrt(dx * dx + dy * dy);
}
double averageDistance = sumOfDistances / corner_count;
I am assuming here that corner_count
is the number of features. You would need to make sure that is indeed correct. Also, I haven't tried to compile this. If I had made any mistakes, it would be up to you to fix them.
However, if you are planning to do image processing more than just this one time, I suggest that you actually learn some programming. What I did here is very basic stuff. Without understanding this for yourself you will not get very far.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…