Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Optical Flow vizualization

$
0
0
I am trying to visualize the output of `calcOpticalFlowPyrLK()`. The problem is, I can't get to the output as in the examples. Every 10 frames I renew the points for the calculation of the flow. When drawing them I use simple code: for (size_t i = 0; i < CornersCentroidNow.size(); i++){ if (feat_errors[i] > MAX_ERR || feat_found[i] == 0) continue; Point p0(ceil(mc[i].x), ceil(mc[i].y)); // are the points of interest (centroids of contours) Point p1(ceil(CornersCentroidNow[i].x), ceil(CornersCentroidNow[i].y)); arrowedLine(empty, p0, p1, Scalar(0, 0, 255), 2, 8, 0, 0.2); } after this block of code. When I draw them every frame I get this output: ![nothing](/upfiles/14554785543356236.png) If I update the previous frame used for `calcOpticalFlowPyrLK()` function CentroidFrOld = CentroidFrNow.clone(); I get this output (the line is short and it is moving foward every 10 frames - as set to get new points) ![Added](/upfiles/14554787111273124.png) If I swap the prew points and next points as well CentroidFrOld = CentroidFrNow.clone(); mc = CornersCentroidNow; I get this output (the line is short, but it is moving along with the object) ![All_up](/upfiles/14554789078494793.png) What I aim to get is a long straight arrow aiming in the right direction, but I am not able to achieve something similar as in the [flow tutorial](http://docs.opencv.org/master/d7/d8b/tutorial_py_lucas_kanade.html#gsc.tab=0). The only thing that author doesn't do is to find new points every few frames. Something like this ![Desired out](/upfiles/1455479483760884.png)

Viewing all articles
Browse latest Browse all 41027

Trending Articles