Ask Your Question

net.cat's profile - activity

2016-04-25 16:21:12 -0600 received badge  Popular Question (source)
2012-11-05 12:06:08 -0600 asked a question Android - OpticalFlow: calcOpticalFlowPyrLK & goodFeaturesToTrack return same points

I'm working on an Android video stabilization application! I got some problem related with goodfeaturestotrack and calcOpticalFlowPyrLK functions 'cause the final output is the same points! I googled every single site regarding this but I wasn't able to solve it! What's wrong with my code?

mRgba1 = new Mat(height, width, CvType.CV_8UC4);
mRgba2 = new Mat(height, width, CvType.CV_8UC4);
mGray1 = new Mat(mRgba1.size(), CvType.CV_8UC1);
mGray2 = new Mat(mRgba2.size(), CvType.CV_8UC1);
mView = new Mat(height, width, CvType.CV_8UC4);
initial = new MatOfPoint();
status = new MatOfByte();
err = new MatOfFloat();
mask = new Mat(mRgba1.size(), CvType.CV_8UC1);
prevPts = new MatOfPoint2f();
nextPts = new MatOfPoint2f();
Imgproc.goodFeaturesToTrack(mGray1, initial, maxCorners, 0.01, 0.01);
initial.convertTo(prevPts, CvType.CV_32FC2);
Video.calcOpticalFlowPyrLK(mGray1, mGray2, prevPts, nextPts, status, err, winSize, 5, optical_flow_termination_criteria, 0, 1);

Then, when I show them:

Point[] pointp = prevPts.toArray();
Point[] pointn = nextPts.toArray();
for (Point px : pointp) 
{ Core.circle(mView, px, 15, circleColor); }
for (Point py : pointn) 
{ Core.circle(mView, py, 5, line_color); }

I got 2 different circles in the same position, and that's not good :(