1

私は、Matlab のビルトイン ビジョン関数と事前に作成されたサンプル コードを使用して、特徴点を追跡しています。私のサンプル ビデオでは、カメラが水平方向にパンし、新しいオブジェクトや風景が視野に入る一方で、前のオブジェクトや風景が視界の外に移動します。

カメラがシーン全体をパンしているときに新しい特徴点を特定しようとすると、問題が発生します。指定された数のフレームがステップスルーされた後に新しい特徴点を見つけるために、ビデオステップ while ループ内で「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);
4

1 に答える 1

1

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

さて、その同じ中でif、ポイントトラッカーにそれらの新しいポイントについて伝える必要があります:

setPoints(tracker, points);

そうしないと、変数pointsは次の行で上書きされます。

[points, isFound] = step(pointTracker, videoFrame);

これが、新しく検出されたポイントが表示されない理由です。

于 2014-12-09T14:58:33.573 に答える