필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tracking and Motion Estimation에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by