使用Matlab重新建立新的特征点';视觉功能
我使用Matlab的内置视觉功能和预先制作的示例代码来跟踪特征点。在我的示例视频中,相机水平平移,将新对象和景物引入视野,而以前的对象和景物移出视野 当摄影机在场景中平移时,尝试识别新的特征点时会出现问题。我在视频步进循环中使用“detectMinEigenFeatures”功能,以便在经过指定数量的帧后查找新的特征点。但是,这样做对重新建立新的特征点毫无帮助 一些快速信息:使用GoPro视频,采样至720p并保存为.avi 代码发布在下面,我很乐意提供更多的信息来帮助理解或解决这个问题 谢谢使用Matlab重新建立新的特征点';视觉功能,matlab,computer-vision,matlab-cvst,feature-tracking,Matlab,Computer Vision,Matlab Cvst,Feature Tracking,我使用Matlab的内置视觉功能和预先制作的示例代码来跟踪特征点。在我的示例视频中,相机水平平移,将新对象和景物引入视野,而以前的对象和景物移出视野 当摄影机在场景中平移时,尝试识别新的特征点时会出现问题。我在视频步进循环中使用“detectMinEigenFeatures”功能,以便在经过指定数量的帧后查找新的特征点。但是,这样做对重新建立新的特征点毫无帮助 一些快速信息:使用GoPro视频,采样至720p并保存为.avi 代码发布在下面,我很乐意提供更多的信息来帮助理解或解决这个问题 谢谢
clc;clear all;close all;
videoFileReader = vision.VideoFileReader('GoProFlyingMidFlightResized.avi');
videoFrame = step(videoFileReader);
%Create Video writer
TrackingVideo = VideoWriter('TrackingVideo.avi');
open(TrackingVideo);
% Detect feature points
points = detectMinEigenFeatures(rgb2gray(videoFrame),'MinQuality',0.04,'FilterSize',3);
% points = detectMinEigenFeatures(rgb2gray(videoFrame));
% Create a point tracker
pointTracker = vision.PointTracker('NumPyramidLevels',7,'MaxBidirectionalError', 8, 'MaxIterations',70,'BlockSize',[5 5]);
% Initialize the tracker with the initial point locations and the initial
% video frame.
points = points.Location;
initialize(pointTracker, points, videoFrame);
videoPlayer = vision.VideoPlayer('Position',[100 100 [size(videoFrame, 2), size(videoFrame, 1)]+30]);
% Make a copy of the points for transformation between the consecutive feature points
oldPoints = points;
FrameCount=0; %For identifying that new feature points must be obtain
while ~isDone(videoFileReader)
% get the next frame
FrameCount=FrameCount+1;
videoFrame = step(videoFileReader);
if FrameCount==30 %If 30 frame have stepped though, find new feature points
disp('help')
points = detectMinEigenFeatures(rgb2gray(videoFrame),'MinQuality',0.04,'FilterSize',3);
points = points.Location;
FrameCount=0;
end
% Track the points.
[points, isFound] = step(pointTracker, videoFrame);
visiblePoints = points(isFound, :);
oldInliers = oldPoints(isFound, :);
if size(visiblePoints, 1) >= 2 % need at least 2 points
% Estimate the geometric transformation between the old points
% and the new points and eliminate outliers
[xform, oldInliers, visiblePoints] = estimateGeometricTransform(oldInliers, visiblePoints, 'similarity', 'MaxDistance', 10);
% Display tracked points
videoFrame = insertMarker(videoFrame, visiblePoints, '+','Color', 'red');
% Reset the points
oldPoints = visiblePoints;
setPoints(pointTracker, oldPoints);
end
% Display video frame using the video player
writeVideo(TrackingVideo,videoFrame);
step(videoPlayer, videoFrame);
end
% Clean up
release(videoFileReader);
release(videoPlayer);
release(pointTracker);
close(TrackingVideo);
在if语句中,检测到新点:
if FrameCount==30 %If 30 frame have stepped though, find new feature points
disp('help')
points = detectMinEigenFeatures(rgb2gray(videoFrame),'MinQuality',0.04,'FilterSize',3);
points = points.Location;
FrameCount=0;
end
setPoints(tracker, points);
现在,在相同的if
中,您必须告诉点跟踪器有关这些新点的信息:
if FrameCount==30 %If 30 frame have stepped though, find new feature points
disp('help')
points = detectMinEigenFeatures(rgb2gray(videoFrame),'MinQuality',0.04,'FilterSize',3);
points = points.Location;
FrameCount=0;
end
setPoints(tracker, points);
否则,变量点
将被下一行覆盖:
[points, isFound] = step(pointTracker, videoFrame);
这就是为什么您从未看到新检测到的点。谢谢Dima,这确实是问题所在。我感谢你的帮助!不客气。我很好奇,8是点跟踪器的
'MaxBidirectionalError'
参数的合理值吗?你不觉得这样会有很多不好的音轨吗?确实是这样,但这只是为了测试的目的,让我对这个特定视频的属性敏感度有一个很好的了解。我使用2进行实际的测试运行。