我正在开发一个 Android 视频稳定应用程序!我遇到了一些与 goodfeaturestotrack 和 calcOpticalFlowPyrLK 函数相关的问题,因为最终输出是相同的点!我用谷歌搜索了每一个关于这个的网站,但我无法解决它!我的代码有什么问题?
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);
然后,当我向他们展示时:
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); }
我在同一个位置有 2 个不同的圆圈,这不好:(