How to find width and height of bounding box after using vision.blobanalysis?

5 views (last 30 days)
For example, after this code,
hsrc = vision.VideoFileReader('mv2_001.avi');
hfg = vision.ForegroundDetector(...
'NumTrainingFrames', 10, ... % 5 because of short video
'InitialVariance', 30*30); % initial standard deviation of 30
hblob = vision.BlobAnalysis(...
'CentroidOutputPort', false, 'AreaOutputPort', false, ...
'BoundingBoxOutputPort', true, ...
'MinimumBlobAreaSource', 'Property', 'MinimumBlobArea', 250);
hsi = vision.ShapeInserter('BorderColor', 'White');
hsnk = vision.VideoPlayer();
while ~isDone(hsrc)
frame = step(hsrc);
fgMask = step(hfg, frame);
bbox = step(hblob, fgMask);
out = step(hsi, frame, bbox); % draw bounding boxes around cars
step(hsnk, out);
% view results in the video player
end
release(hsnk);
release(hsrc);
I want to track objects whose bounding box width is less than certain threshold. Pease help.

Answers (1)

Dima Lisin
Dima Lisin on 1 Jul 2014
Edited: Dima Lisin on 1 Jul 2014
In your example bbox is an M-by-4 matrix containing the bounding boxes represented as [x y w h]. First, you should delete the rows in which 3-rd element (the width) is less then your threshold. To learn how to track the blobs from frame to frame take a look at this example .

Community Treasure Hunt

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

Start Hunting!