error using blobAnalysis/step

3 visualizaciones (últimos 30 días)
izza aditya
izza aditya el 27 de Ag. de 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);

Respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by