ViSP  2.6.2
vpDiskGrabber Class Reference

#include <vpDiskGrabber.h>

+ Inheritance diagram for vpDiskGrabber:

Public Member Functions

 vpDiskGrabber ()
 
 vpDiskGrabber (const char *genericName)
 
 vpDiskGrabber (const char *dir, const char *basename, long number, int step, unsigned int noz, const char *ext)
 
virtual ~vpDiskGrabber ()
 
void open (vpImage< unsigned char > &I)
 
void open (vpImage< vpRGBa > &I)
 
void acquire (vpImage< unsigned char > &I)
 
void acquire (vpImage< vpRGBa > &I)
 
void acquire (vpImage< unsigned char > &I, long image_number)
 
void acquire (vpImage< vpRGBa > &I, long image_number)
 
void close ()
 
void setDirectory (const char *dir)
 
void setBaseName (const char *name)
 
void setImageNumber (long number)
 
void setStep (int a)
 
void setNumberOfZero (unsigned int noz)
 
void setExtension (const char *ext)
 
void setGenericName (const char *genericName)
 
long getImageNumber ()
 
unsigned int getHeight () const
 
unsigned int getWidth () const
 

Public Attributes

bool init
 

Protected Attributes

unsigned int height
 
unsigned int width
 

Detailed Description

Class to grab (ie. read) images from the disk.

Defined a virtual video device. "Grab" the images from the disk. Derived from the vpFrameGrabber class.

See also
vpFrameGrabber

Here an example of capture from the directory "/local/soft/ViSP/ViSP-images/cube". We want to acquire 10 images from the first named "image.0001.pgm" by steps of 2.

#include <visp/vpImage.h>
#include <visp/vpDiskGrabber.h>
int main(){
vpImage<unsigned char> I; // Grey level image
// Declare a framegrabber able to read a sequence of successive
// images from the disk
// Set the path to the directory containing the sequence
g.setDirectory("/local/soft/ViSP/ViSP-images/cube");
// Set the image base name. The directory and the base name constitute
// the constant part of the full filename
g.setBaseName("image.");
// Set the step between two images of the sequence
g.setStep(2);
// Set the number of digits to build the image number
// Set the first frame number of the sequence
// Set the image file extension
g.setExtension("pgm");
// Open the framegrabber by loading the first image of the sequence
g.open(I) ;
unsigned int cpt = 1;
// this is the loop over the image sequence
while(cpt ++ < 10)
{
// read the image and then increment the image counter so that the next
// call to acquire(I) will get the next image
g.acquire(I) ;
}
}
Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 110 of file vpDiskGrabber.h.

Constructor & Destructor Documentation

vpDiskGrabber::vpDiskGrabber ( )

Elementary constructor.

Definition at line 49 of file vpDiskGrabber.cpp.

References vpFrameGrabber::init, setBaseName(), setDirectory(), setExtension(), setImageNumber(), setNumberOfZero(), and setStep().

vpDiskGrabber::vpDiskGrabber ( const char *  genericName)

Definition at line 63 of file vpDiskGrabber.cpp.

vpDiskGrabber::vpDiskGrabber ( const char *  dir,
const char *  basename,
long  number,
int  step,
unsigned int  noz,
const char *  ext 
)

Constructor.

Parameters
dir: Location of the image sequence.
basename: Base name of each image.
number: Initial image number.
step: Increment between two images.
noz: Number of zero to code the image number.
ext: Extension of the image file.

Definition at line 81 of file vpDiskGrabber.cpp.

References vpFrameGrabber::init, setBaseName(), setDirectory(), setExtension(), setImageNumber(), setNumberOfZero(), and setStep().

vpDiskGrabber::~vpDiskGrabber ( )
virtual

Destructor

In fact nothing to destroy...

Definition at line 263 of file vpDiskGrabber.cpp.

Member Function Documentation

void vpDiskGrabber::acquire ( vpImage< unsigned char > &  I)
virtual

Acquire an image: read a pgm image from the disk. After this call, the image number is incremented considering the step.

Parameters
Ithe read image

Implements vpFrameGrabber.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 145 of file vpDiskGrabber.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpImageIo::read(), vpDEBUG_TRACE, and vpFrameGrabber::width.

Referenced by vpVideoReader::acquire(), vpVideoReader::getFrame(), and open().

void vpDiskGrabber::acquire ( vpImage< vpRGBa > &  I)
virtual

Acquire an image: read a ppm image from the disk. After this call, the image number is incremented considering the step.

Parameters
Ithe read image

Implements vpFrameGrabber.

Definition at line 172 of file vpDiskGrabber.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpImageIo::read(), vpDEBUG_TRACE, and vpFrameGrabber::width.

void vpDiskGrabber::acquire ( vpImage< unsigned char > &  I,
long  image_number 
)

Acquire an image: read a pgm image from the disk. After this call, the image number is incremented considering the step.

Parameters
Ithe read image
image_numberThe index of the desired image.

Definition at line 201 of file vpDiskGrabber.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpImageIo::read(), vpDEBUG_TRACE, and vpFrameGrabber::width.

void vpDiskGrabber::acquire ( vpImage< vpRGBa > &  I,
long  image_number 
)

Acquire an image: read a ppm image from the disk. After this call, the image number is incremented considering the step.

Parameters
Ithe read image
image_numberThe index of the desired image.

Definition at line 227 of file vpDiskGrabber.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpImageIo::read(), vpDEBUG_TRACE, and vpFrameGrabber::width.

void vpDiskGrabber::close ( )
virtual

Not useful

Here for compatibility issue with the vpFrameGrabber class

Implements vpFrameGrabber.

Definition at line 252 of file vpDiskGrabber.cpp.

unsigned int vpFrameGrabber::getHeight ( ) const
inlineinherited

Return the number of rows in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 119 of file vpFrameGrabber.h.

Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().

long vpDiskGrabber::getImageNumber ( )
inline

Return the current image number.

Definition at line 153 of file vpDiskGrabber.h.

Referenced by open().

unsigned int vpFrameGrabber::getWidth ( ) const
inlineinherited

Return the number of columns in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 121 of file vpFrameGrabber.h.

Referenced by vp1394Grabber::acquire(), and vp1394Grabber::open().

void vpDiskGrabber::open ( vpImage< vpRGBa > &  I)
virtual

Read the fist image of the sequence. The image number is not incremented.

Implements vpFrameGrabber.

Definition at line 120 of file vpDiskGrabber.cpp.

References acquire(), vpImage< Type >::getHeight(), getImageNumber(), vpImage< Type >::getWidth(), vpFrameGrabber::height, vpFrameGrabber::init, setImageNumber(), vpDEBUG_TRACE, and vpFrameGrabber::width.

void vpDiskGrabber::setBaseName ( const char *  name)

Set the image base name.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 281 of file vpDiskGrabber.cpp.

Referenced by vpDiskGrabber().

void vpDiskGrabber::setDirectory ( const char *  dir)

Set the main directory name (ie location of the image sequence)

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 272 of file vpDiskGrabber.cpp.

Referenced by vpDiskGrabber().

void vpDiskGrabber::setExtension ( const char *  ext)

Set the image extension.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 290 of file vpDiskGrabber.cpp.

Referenced by vpDiskGrabber().

void vpDiskGrabber::setGenericName ( const char *  genericName)

Definition at line 324 of file vpDiskGrabber.cpp.

Referenced by vpVideoReader::open().

void vpDiskGrabber::setImageNumber ( long  number)

Set the number of the image to be read.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 299 of file vpDiskGrabber.cpp.

References vpDEBUG_TRACE.

Referenced by open(), vpVideoReader::open(), and vpDiskGrabber().

void vpDiskGrabber::setNumberOfZero ( unsigned int  noz)

Set the step between two images.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 318 of file vpDiskGrabber.cpp.

Referenced by vpDiskGrabber().

void vpDiskGrabber::setStep ( int  step)

Set the step between two images.

Examples:
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 310 of file vpDiskGrabber.cpp.

Referenced by vpDiskGrabber().

Member Data Documentation