[英]Image detection and tracking on a video using MATLAB
我这里有一个倒立的钟摆视频,长度为33秒。 目的是在摆的移动矩形部分的中心绘制一个红点,并沿着黑棒绘制一条线,计算出每一帧的角度。
我已逐帧处理视频。 然后,我使用点特征匹配在杂乱场景中使用了对象检测 。 如果我可以访问匹配点的索引,然后可以轻松地计算角度,那就太好了。
我以为我可以获取移动的矩形部分的区域并在下一帧中寻找相似的区域。 但是这种解决方案似乎太本地化了。
我不知道要应用哪些技术。
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
如果您的相机不动,这将使问题变得更加容易。 如果使用固定摄像机(例如,安装在三脚架上)拍摄视频,则可以使用vision.ForegroundDetector
从静态背景中分割出移动的物体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.