這是從視頻中檢測對象的代碼。如何在matlab中從圖像中裁剪多個對象
我想從這個視頻逐幀裁剪對象。
videoSource = vision.VideoFileReader('viptraffic.avi','ImageColorSpace','Intensity'...
'VideoOutputDataType','uint8');
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 5, ...
'InitialVariance', 30*30);
blob = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', 250);
shapeInserter = vision.ShapeInserter('BorderColor','White');
videoPlayer = vision.VideoPlayer();
while ~isDone(videoSource)
frame = step(videoSource);
fgMask = step(detector, frame);
bbox = step(blob, fgMask);
out = step(shapeInserter, frame, bbox);
step(videoPlayer, out);
end
release(videoPlayer);
release(videoSource);
,當我想從裁剪框 BBOX它總是給我的錯誤「無效的輸入參數」
如果我寫這個命令。
frame(bbox(1):bbox(1)+bbox(3), bbox(2):bbox(2)+bbox(4), :);
「索引超出矩陣尺寸」錯誤來了。 請幫助我如何從圖像
我不知道如何將x任意y更改爲row-column @Shai –
@ user3551081您只需更改我在答案中寫的順序。嘗試發現您的代碼行與我的區別。 – Shai
是的,我試過這個,但同樣的錯誤 –