使用MATLAB对视频进行图像检测和跟踪

时间:2014-05-20 10:36:27

标签: matlab image-processing matlab-cvst

我有倒立摆视频here,长度为33秒。目标是在摆锤的移动矩形部分的中心绘制一个红点,并绘制一条沿着黑棒计算每个帧的角度的线。

我已经逐帧处理了视频。然后我使用了Object Detection In A Cluttered Scene Using Point Feature Matching。如果我可以访问匹配点的索引,那么我会很容易地计算出角度。

我原以为我可以得到移动的矩形部分区域并在下一帧中寻找相似的区域。但这个解决方案看起来太局部了。

我不知道应用哪种技术。

clear all;
clc;

hVideoFileReader = vision.VideoFileReader;
hVideoPlayer = vision.VideoPlayer;

hVideoFileReader.Filename = 'inverted-pendulum.avi';

hVideoFileReader.VideoOutputDataType = 'single';

while ~isDone(hVideoFileReader)

    grayFrame = rgb2gray(step(hVideoFileReader)); 
    frame = step(hVideoFileReader); 

    if isFirstFrame
        part = grayFrame(202:266,202:282); % #moving part's region
        isFirstFrame = false;
        subplot(1,2,1);
        imshow(part);
    end

    partPoints = detectSURFFeatures(part);
    grayFramePoints = detectSURFFeatures(grayFrame);


    hold on;
    subplot(1,2,1),    plot(partPoints .selectStrongest(10));    
    subplot(1,2,2),    imshow(grayFrame);

    subplot(1,2,2),    plot(grayFramePoints .selectStrongest(20));


    frame2 = pointPendulumCenter(frame);  

    frame3 = plotLineAlongStick(frame2); 

    step(hVideoPlayer, frame3); 


    hold off;

end

release(hVideoFileReader);
release(hVideoPlayer);


%% #Function to find the moving part's center point and plot a red dot on it.
function f = pointPendulumCenter(frame)
end

%% #Function to plot a red line along the stick after calculating the angle of it.
function f = plotLineAlongStick(frame)
end

1 个答案:

答案 0 :(得分:0)

如果您的相机没有移动,这将使问题更容易。如果您使用固定摄像头拍摄视频(例如安装在三脚架上),则可以使用vision.ForegroundDetector从静态背景中分割出移动的物体。

相关问题