フィルターのクリア

error using blobAnalysis/step

1 回表示 (過去 30 日間)
izza aditya
izza aditya 2019 年 8 月 27 日
filename = '../dataset/video.avi';
hsrc = vision.VideoFileReader(filename,'ImageColorSpace','RGB','VideoOutputDataType','uint8');
% ------------------------------------------------------------------------------------------
blobAnalysis = vision.BlobAnalysis('BoundingBoxOutputPort', true, ...
'AreaOutputPort', true, 'CentroidOutputPort', true, ...
'MinimumBlobArea', 50);
se = strel('square',3);
% -------------------------------------------------------------------------------------------
% Create background/foreground segmentation object
hfg = backgroundSubtractor(algorithm);
disp('Starting...');
frameCnt = 1;
while ~isDone(hsrc), %disp(frameCnt)
% Read frame
frame = step(hsrc);
% Compute foreground mask and background model
[fgMask, bgModel] = getForegroundMask(hfg, frame);
%--------------------------------------------------------------------------
filteredForeground = imopen(fgMask, se);
bbox = step(blobAnalysis, filteredForeground);
result = insertShape(hsrc, 'Rectangle', bbox, 'Color', 'green');
numCars = size(bbox, 1);
result = insertText(result, [10 10], numCars, 'BoxOpacity', 1, ...
% 'FontSize', 14);
%--------------------------------------------------------------------------
% View results
subplot(2,3,1), imshow(frame,'InitialMagnification','fit');
subplot(2,3,2), imshow(filteredForeground,'InitialMagnification','fit');
subplot(2,3,3), imshow(bgModel,'InitialMagnification','fit');
subplot(2,3,4), imshow(fgMask,'InitialMagnification','fit');
pause(0.01);
% Reset background model
% This step just demonstrates how to use reset method
if (frameCnt==5)
%reset(hfg);
%break;
end
frameCnt = frameCnt + 1;
end
disp('Finished!');
release(hfg);
release(hsrc);

回答 (0 件)

カテゴリ

Help Center および File ExchangeTracking and Motion Estimation についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by