Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpDiskGrabber Class Reference

#include <vpDiskGrabber.h>

Inheritance diagram for vpDiskGrabber:

Public Member Functions

 vpDiskGrabber ()
 vpDiskGrabber (const vpDiskGrabber &grabber)
VP_EXPLICIT vpDiskGrabber (const std::string &genericName)
virtual ~vpDiskGrabber () VP_OVERRIDE
vpDiskGrabberoperator= (const vpDiskGrabber &grabber)
VP_EXPLICIT vpDiskGrabber (const std::string &dir, const std::string &basename, long number, int step, unsigned int noz, const std::string &ext)
void acquire (vpImage< unsigned char > &I) VP_OVERRIDE
void acquire (vpImage< vpRGBa > &I) VP_OVERRIDE
void acquire (vpImage< float > &I)
void acquire (vpImage< unsigned char > &I, long image_number)
void acquire (vpImage< vpRGBa > &I, long image_number)
void acquire (vpImage< float > &I, long image_number)
void close () VP_OVERRIDE
long getImageNumber () const
std::string getImageName () const
void open (vpImage< unsigned char > &I) VP_OVERRIDE
void open (vpImage< vpRGBa > &I) VP_OVERRIDE
void open (vpImage< float > &I)
void setBaseName (const std::string &name)
void setDirectory (const std::string &dir)
void setExtension (const std::string &ext)
void setGenericName (const std::string &genericName)
void setImageNumber (long number)
void setNumberOfZero (unsigned int noz)
void setStep (long step)

Public Attributes

bool init

Inherited functionalities from vpFramegrabber

unsigned int getHeight () const
unsigned int getWidth () const
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 <visp3/core/vpImage.h>
#include <visp3/io/vpDiskGrabber.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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) ;
}
}
void setStep(long step)
void setDirectory(const std::string &dir)
void setExtension(const std::string &ext)
void open(vpImage< unsigned char > &I) VP_OVERRIDE
void acquire(vpImage< unsigned char > &I) VP_OVERRIDE
void setImageNumber(long number)
void setNumberOfZero(unsigned int noz)
void setBaseName(const std::string &name)
Definition of the vpImage class member functions.
Definition vpImage.h:131
Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 108 of file vpDiskGrabber.h.

Constructor & Destructor Documentation

◆ vpDiskGrabber() [1/4]

BEGIN_VISP_NAMESPACE vpDiskGrabber::vpDiskGrabber ( )

Default constructor.

Definition at line 39 of file vpDiskGrabber.cpp.

References vpFrameGrabber::init.

Referenced by operator=(), and vpDiskGrabber().

◆ vpDiskGrabber() [2/4]

vpDiskGrabber::vpDiskGrabber ( const vpDiskGrabber & grabber)

Copy constructor.

Definition at line 46 of file vpDiskGrabber.cpp.

References vpDiskGrabber(), and vpFrameGrabber::vpFrameGrabber().

◆ vpDiskGrabber() [3/4]

vpDiskGrabber::vpDiskGrabber ( const std::string & genericName)

Constructor that takes a generic image sequence as input.

Definition at line 66 of file vpDiskGrabber.cpp.

References vpFrameGrabber::init.

◆ ~vpDiskGrabber()

virtual vpDiskGrabber::~vpDiskGrabber ( )
inlinevirtual

Destructor. In fact nothing to destroy...

Definition at line 145 of file vpDiskGrabber.h.

◆ vpDiskGrabber() [4/4]

vpDiskGrabber::vpDiskGrabber ( const std::string & dir,
const std::string & basename,
long number,
int step,
unsigned int noz,
const std::string & 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 73 of file vpDiskGrabber.cpp.

References vpFrameGrabber::init.

Member Function Documentation

◆ acquire() [1/6]

void vpDiskGrabber::acquire ( vpImage< float > & I)

Acquire an image reading the next image from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.

Definition at line 170 of file vpDiskGrabber.cpp.

References visp::cnpy::NpyArray::data(), vpIoTools::formatString(), vpIoTools::getFileExtension(), vpFrameGrabber::height, vpException::ioError, visp::cnpy::npy_load(), vpImageIo::read(), visp::cnpy::NpyArray::shape, vpIoTools::toLowerCase(), and vpFrameGrabber::width.

◆ acquire() [2/6]

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

Acquire an image reading the pfm image with number img_number from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.
image_number: The number of the desired image.

Definition at line 249 of file vpDiskGrabber.cpp.

References vpIoTools::formatString(), vpFrameGrabber::height, vpImageIo::readPFM(), and vpFrameGrabber::width.

◆ acquire() [3/6]

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

Acquire an image reading the next image from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.

Implements vpFrameGrabber.

Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 127 of file vpDiskGrabber.cpp.

References vpIoTools::formatString(), vpFrameGrabber::height, vpImageIo::read(), and vpFrameGrabber::width.

Referenced by open(), open(), and open().

◆ acquire() [4/6]

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

Acquire an image reading the image with number img_number from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.
image_number: The number of the desired image.

Definition at line 205 of file vpDiskGrabber.cpp.

References vpIoTools::formatString(), vpFrameGrabber::height, vpImageIo::read(), and vpFrameGrabber::width.

◆ acquire() [5/6]

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

Acquire an image reading the next image from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.

Implements vpFrameGrabber.

Definition at line 148 of file vpDiskGrabber.cpp.

References vpIoTools::formatString(), vpFrameGrabber::height, vpImageIo::read(), and vpFrameGrabber::width.

◆ acquire() [6/6]

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

Acquire an image reading the image with number img_number from the disk. After this call, the image number is incremented considering the step.

Parameters
I: The image read from a file.
image_number: The number of the desired image.

Definition at line 227 of file vpDiskGrabber.cpp.

References vpIoTools::formatString(), vpFrameGrabber::height, vpImageIo::read(), and vpFrameGrabber::width.

◆ close()

void vpDiskGrabber::close ( )
inlinevirtual

Not useful.

Does nothing. Here for compatibility issue with the vpFrameGrabber class.

Implements vpFrameGrabber.

Definition at line 221 of file vpDiskGrabber.h.

◆ getHeight()

BEGIN_VISP_NAMESPACE unsigned int vpFrameGrabber::getHeight ( ) const
inherited

Return the number of rows in the image.

Examples
AROgre.cpp, AROgreBasic.cpp, testPylonGrabber.cpp, and tutorial-rbt-sequence.cpp.

Definition at line 38 of file vpFrameGrabber.cpp.

References height.

◆ getImageName()

std::string vpDiskGrabber::getImageName ( ) const
inline

Return the name of the file in which the last frame was read.

Definition at line 231 of file vpDiskGrabber.h.

◆ getImageNumber()

long vpDiskGrabber::getImageNumber ( ) const
inline

Return the current image number.

Examples
grabDisk.cpp, and grabDiskFloat.cpp.

Definition at line 226 of file vpDiskGrabber.h.

Referenced by open(), open(), and open().

◆ getWidth()

unsigned int vpFrameGrabber::getWidth ( ) const
inherited

Return the number of columns in the image.

Examples
AROgre.cpp, AROgreBasic.cpp, testPylonGrabber.cpp, and tutorial-rbt-sequence.cpp.

Definition at line 43 of file vpFrameGrabber.cpp.

References width.

◆ open() [1/3]

void vpDiskGrabber::open ( vpImage< float > & I)

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

Definition at line 111 of file vpDiskGrabber.cpp.

References acquire(), getImageNumber(), vpFrameGrabber::height, vpFrameGrabber::init, setImageNumber(), and vpFrameGrabber::width.

◆ open() [2/3]

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

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

Implements vpFrameGrabber.

Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 81 of file vpDiskGrabber.cpp.

References acquire(), getImageNumber(), vpFrameGrabber::height, vpFrameGrabber::init, setImageNumber(), and vpFrameGrabber::width.

◆ open() [3/3]

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

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

Implements vpFrameGrabber.

Definition at line 95 of file vpDiskGrabber.cpp.

References acquire(), getImageNumber(), vpFrameGrabber::height, vpFrameGrabber::init, setImageNumber(), and vpFrameGrabber::width.

◆ operator=()

vpDiskGrabber & vpDiskGrabber::operator= ( const vpDiskGrabber & grabber)

Copy operator.

Definition at line 51 of file vpDiskGrabber.cpp.

References vpDiskGrabber().

◆ setBaseName()

void vpDiskGrabber::setBaseName ( const std::string & name)
inline

Set the image base name.

Examples
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 254 of file vpDiskGrabber.h.

◆ setDirectory()

void vpDiskGrabber::setDirectory ( const std::string & dir)
inline

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

Examples
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 259 of file vpDiskGrabber.h.

◆ setExtension()

void vpDiskGrabber::setExtension ( const std::string & ext)
inline

Set the image extension.

Examples
grabDisk.cpp, and manGrabDisk.cpp.

Definition at line 264 of file vpDiskGrabber.h.

◆ setGenericName()

void vpDiskGrabber::setGenericName ( const std::string & genericName)

Set the image generic name like image-%04d.png.

Examples
grabDiskFloat.cpp.

Definition at line 277 of file vpDiskGrabber.cpp.

◆ setImageNumber()

void vpDiskGrabber::setImageNumber ( long number)

Set the number of the image to be read.

Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 271 of file vpDiskGrabber.cpp.

Referenced by open(), open(), and open().

◆ setNumberOfZero()

void vpDiskGrabber::setNumberOfZero ( unsigned int noz)
inline

Set the step between two images.

Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 279 of file vpDiskGrabber.h.

◆ setStep()

void vpDiskGrabber::setStep ( long step)
inline

Set the step between two images.

Examples
grabDisk.cpp, grabDiskFloat.cpp, and manGrabDisk.cpp.

Definition at line 284 of file vpDiskGrabber.h.

Member Data Documentation

◆ height

◆ init

◆ width