我有一個倒立擺視頻here,它的長度爲33秒。目標是在擺的移動矩形部分的中心繪製一個紅點,並繪製黑線上每條線的角度。使用MATLAB對視頻進行圖像檢測和跟蹤
我已經逐幀處理了視頻。然後我用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(可能是兩張圖片),你會得到多少。您應該發佈這些功能的代碼。您提供的代碼不會增加太多價值。此外,添加一些人們可以使用的靜態圖像,在其中添加一些其他圖像。手工繪製以準確顯示您想要達到的效果。我認爲你需要縮小你的問題,因爲目前這個問題相當廣泛。 – kkuilla