我在相对较小(288 x 360)的交通视频上使用光流,我遇到了问题。我无法获得帧中某些地方的光流向量。这张图片显示了被检测为“要跟踪的好特征”的点
goodFeaturesToTrack()
像这样的功能:
vector<Point2f> features1;
vector<Point2f> features2;
int number_of_features = 2000;
goodFeaturesToTrack(frame1, features1 ,number_of_features,0.01,0.01);
你会看到在后面检测到很多点但是当我使用
calcOpticalFlowPyrLK()
得到这样的光流向量:
TermCriteria optical_flow_termination_criteria= TermCriteria( CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 10, .001 );
calcOpticalFlowPyrLK(
frame1, frame2, features1, features2,
optical_flow_found_feature,optical_flow_feature_error,
Size(21,21),5,optical_flow_termination_criteria
);
它只返回前面的点,如图像中的那样:
但我需要所有视频的矢量。那么我怎样才能从后面获取向量呢?
编辑:
我做错的是我在过滤小向量。