MATLAB Answers

## How to get co-ordinates of the detected blobs in a video frame?

Asked by sangeetha N

### sangeetha N (view profile)

on 8 Feb 2019
This programming code is done in Scilab,very much similar to matlab. I have detected features of vehicles and I need to co-ordinates of them or I need their position.What should I do?
Here is the reference code:-
n = aviopen('F:\Rec_2018-12-21 h18_m7_s29.avi'); //open the video file
for i=1:20
im = avireadframe(n,i);
subplot(3,2,1);
imshow(im); //show the images
title('orginal video image'); //title name
loop = rectangle(im,[80, 40, 50, 40],[255 255 255]); //rectangle fixed loop of white clr drawn
subplot(3,2,2);
imshow(loop); // rectangle drawn on input image
se = imcreatese('rect',3,3);
S_bin = im2bw(sub,imgraythresh(im));
S2 = imopen(S_bin,se);
[S3,nn] = imlabel(im2bw(S2,imgraythresh(im))); //label-binary img //nn-number of blobs
[Area, BB, ctr] = imblobprop(S3); // Find the object features
if nn ==BB then
loop1 = rectangle(im,[80, 40, 50, 40],[255 0 0]); //rectangle fixed loop of white clr drawn - veh detection
subplot(3,2,2)
imshow(loop1); // rectangle drawn on input image
title('vehicle presence:no'); //veh det yes only when small box comes inside big box
else
loop1 = rectangle(im,[80, 40, 50, 40],[255 255 255]); //rectangle fixed loop clr changed to red clr
subplot(3,2,2)
imshow(loop1); // rectangle drawn on input image
title('vehicle presence:yes');
end
end
aviclose();
avicloseall();
Here, blobs are not detected properly.Is it because if the function or the size of structuring element?

#### 0 Comments

Sign in to comment.