MATLAB Answers

How to get a frame from output of STEP fuction

4 views (last 30 days)
Mammo Image
Mammo Image on 20 Aug 2016
Commented: Mammo Image on 21 Aug 2016
I used vision.foreground to find the silhouette of moving person. Now I would like to make frame extraction for the output of this code but I dont know how to extract the window that result from step function.
another thing please, why ( out) and ( bbox) variables are zero when I implement the code.
videoSource = vision.VideoFileReader('person01_walking_d1_uncomp.avi','ImageColorSpace','Intensity','VideoOutputDataType','uint8');
detector = vision.ForegroundDetector(...
'NumTrainingFrames', 500, ...
'InitialVariance', 900);
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);
bw2 = bwareaopen (fgMask, 250);
bbox = step(blob, fgMask);
out = step( shapeInserter, bw2,bbox);
step (videoPlayer, out);
  • _ I found the following code for extract frames from video but I dont know where should I put it exactly in the previous code._*
obj = VideoReader('person01_walking_d1_uncomp.avi');
for k = 1 : obj.NumberOfFrames %fill in the appropriate number
this_frame = read(obj, k);
thisfig = figure();
thisax = axes('Parent', thisfig);
image(this_frame, 'Parent', thisax);
title(thisax, sprintf('Frame #%d', k));

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by