我使用它作为我的跟踪算法的基础。使用光流的OpenCV跟踪
//1. detect the features
cv::goodFeaturesToTrack(gray_prev, // the image
features, // the output detected features
max_count, // the maximum number of features
qlevel, // quality level
minDist); // min distance between two features
// 2. track features
cv::calcOpticalFlowPyrLK(
gray_prev, gray, // 2 consecutive images
points_prev, // input point positions in first im
points_cur, // output point positions in the 2nd
status, // tracking success
err); // tracking error
cv::calcOpticalFlowPyrLK
取点的矢量来自先前图像作为输入,并且对下一个图像返回适当点。假设在前一个图像上有随机像素(x,y),如何使用OpenCV光流功能计算下一个图像上该像素的位置?
我注意到你只做一次特征检测。我测试了这个代码。我发现只有在第一张图像上检测到的功能才能被追踪。如果所有这些功能都超出了图像范围,那么就无法跟踪。我需要使用光流进行3D建设。那么我们如何能够持续跟踪旧功能并同时添加新的图像功能?谢谢。 – Shiyu 2012-04-15 02:53:27
是的,你只能用'goodFeaturesToTrack'检测特征,然后光流方法只是跟踪它们。如果要在每个帧中保留一定数量的功能,则必须检测到当前帧有多少功能被成功跟踪,然后尝试检测追加到下一帧的附加功能。另一种方法是在每个帧中检测特征,然后计算描述符并通过使用[本页]上的函数来匹配这些描述符(http://opencv.itseez.com/modules/features2d/doc/features2d.html)。 – Chris 2012-04-16 08:37:32
如果你需要更多的细节,最好问一个新的问题。 – Chris 2012-04-16 08:37:51