【问题标题】:Image detection and tracking on a video using MATLAB使用 MATLAB 对视频进行图像检测和跟踪
【发布时间】:2014-05-20 10:36:26
【问题描述】:

我有一个倒立摆视频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

【问题讨论】:

  • 据我所知,您发布的代码只是读取视频并运行findCenterofRectangle(frame)plotLineAlongStick(frame)。如果您可以添加一个 mcve 来显示(可能有两个图像)您已经走了多远,那就太好了。您应该发布这些功能的代码。您提供的代码不会增加太多价值。此外,添加一些人们可以使用的静态图像,添加一些其他图像,例如手绘以准确显示您想要实现的目标。我认为你需要缩小你的问题范围,因为它目前相当广泛。

标签: matlab image-processing matlab-cvst


【解决方案1】:

如果您的相机不动,问题就会变得容易得多。如果您使用固定相机(例如安装在三脚架上)拍摄视频,则可以使用 vision.ForegroundDetector 从静态背景中分割出移动的物体。

【讨论】:

  • 相机不是完全静止的。它移动了一点
  • 我试过vsion.ForegroundDetector。它在移动段周围绘制白色矩形。但我不知道要处理哪个矩形。我只需要在移动部分的中心绘制一个红点,并在黑棒上绘制一条红线。我已经更新了我的代码。也许你想看看。问候。
  • 你能根据大小或形状确定你需要哪个段吗? regionprops 函数可让您计算各种形状特征。
猜你喜欢
  • 2020-06-26
  • 2012-11-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-22
  • 1970-01-01
  • 2011-09-25
相关资源
最近更新 更多