Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: vision.ForegroundDetector on Images
Replies: 12   Last Post: Feb 28, 2014 5:41 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Witek Jachimczyk

Posts: 132
Registered: 12/7/04
Re: vision.ForegroundDetector on Images
Posted: Mar 29, 2012 12:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.