Effacer les filtres
Effacer les filtres

error using blobAnalysis/step

1 vue (au cours des 30 derniers jours)
izza aditya
izza aditya le 27 Août 2019
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);

Réponses (0)

Catégories

En savoir plus sur Tracking and Motion Estimation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by