Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: vision.ForegroundDetector on Images
Posted:
Mar 29, 2012 12:31 PM
|
|
Hi,
If you'd like to look at a single image a function such as RECTANGLE or ANNOTATION will work well. If you'd like to do it in a loop and then use a video viewer, your best bet is to use vision.ShapeInserter object:
hshapeins = vision.ShapeInserter;
In a loop you'd do something like this:
x = 25; y = 15; width = 40; height = 40; % you'd replace this line with object detection routine which produces % a bounding box in a form [x y width height] rectangle = [x y width height];
J = step(hshapeins, I, pts);
% then display J using vision.VideoViewer
Witek
Gordon <gordon.aguis91@gmail.com> wrote: > Hi, > > Sorry to bother again. Can you please show me how I can modify this code to draw boxes around the detected objects in the images please? > > Thanks so much for your time! > > "Gordon" wrote in message <jkvcvs$t4k$1@newscl01ah.mathworks.com>... > > Thanks a lot! Your help is greatly appreciated. > > > > witek@mathworks.com wrote in message <jkvavm$j01$1@newscl01ah.mathworks.com>... > > > Hi Gordon, > > > > > > We'll consider adding an object like this in the future. > > > In the meantime, you can use the following strategy: > > > > > > imageNames = dir(fullfile(<your directory>,'*.jpg')); > > > imageNames = {imageNames.name}'; > > > > > > % you may need to sort the file names at this point in time, see > > > % http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/imagesAndVideo.html#16 > > > % for details > > > > > > foregroundEst = vision.ForegroundEstimator; > > > > > > for ii = 1:length(imageNames) > > > img = imread(fullfile(workingDir,'images',imageNames{ii})); > > > > > > fg = foregroundEst.step(img); > > > > > > <do whatever else needs to be done> > > > > > > end > > > > > > HTH, > > > > > > Witek > > > > > > > > > Gordon <gordon.aguis91@gmail.com> wrote: > > > > Thanks a lot! Yes, my data changes with time, it is like a video sequence but it is made up of images. > > > > I was wondering whether there exists something like vision.VideoFileReader() but for images instead. > > > > > > > > Thanks.
|
|
|
|