我在论坛中发现了类似的问题.但那里的答案并没有回答我的问题.
如果我在第一张图像上只进行一次特征检测(goodFeaturesToTrack),然后使用光流(calcOpticalFlowPyrLK)来跟踪这些特征,则问题是:只能跟踪第一张图像上检测到的特征.当这些功能超出图像时,就没有可追踪的功能.
如果我对每个新图像进行特征检测,则特征跟踪不稳定,因为此时可能无法检测到上次检测到的特征.
我正在使用光流进行3D重建.所以我对跟踪哪些功能不感兴趣,相反,我只关心是否可以稳定地跟踪视野中的功能.总而言之,我的问题是:如何使用光流跟踪旧功能,同时添加进入视野的新图像功能并删除超出视野范围的旧功能?
我使用以下函数作为我的跟踪算法的基础.
// 1.检测功能我的意思,这个功能提取唯一的好功能,
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
Run Code Online (Sandbox Code Playgroud)
// 2.跟踪功能
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
Run Code Online (Sandbox Code Playgroud)
cv::calcOpticalFlowPyrLK将前一图像中的点矢量作为输入,并在下一图像上返回适当的点.假设我想计算每个像素的光学流量而不是好的特征
换句话说,开始计算从(1,1)到(m,n)的光流