Question

I'm using optical flow on a traffic video which are relatively small (288 x 360) and I have a problem. I can't get the optical flow vectors of some places in the frame. This image shows the points that were detected as "good features to track" by the

goodFeaturesToTrack()

function like this:

vector<Point2f>  features1;
vector<Point2f>  features2;
int number_of_features = 2000;
goodFeaturesToTrack(frame1, features1 ,number_of_features,0.01,0.01);

enter image description here

and you see a lot of points were detected in the back but when I use

calcOpticalFlowPyrLK()

to get the optical flow vectors like this:

TermCriteria optical_flow_termination_criteria= TermCriteria( CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 10, .001 );

calcOpticalFlowPyrLK(
frame1, frame2, features1, features2,
optical_flow_found_feature,optical_flow_feature_error,
Size(21,21),5,optical_flow_termination_criteria
);

it only returns points in the front as in the image blow:

enter image description here

But I need vectors of all the video. So how can I get vectors from the back as well?

Edit:

What I was doing wrong was that I was filtering small vectors.

Was it helpful?

Solution

My guess is that you are doing some kind of processing/filtering of the optical flow vectors before displaying them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top