Visual Servoing Platform  version 3.0.1
manGrabDisk.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Images grabbing example.
32  *
33  * Authors:
34  * Anthony Saunier
35  * Fabien Spindler
36  *
37  *****************************************************************************/
51 #include <visp3/core/vpConfig.h>
52 
53 #include <visp3/core/vpImage.h>
54 #include <visp3/io/vpDiskGrabber.h>
55 
56 int main()
57 {
58  try {
59  vpImage<unsigned char> I; // Grey level image
60 
61  // Declare a framegrabber able to read a sequence of successive
62  // images from the disk
63  vpDiskGrabber g;
64 
65  // Set the path to the directory containing the sequence
66  g.setDirectory("/tmp");
67  // Set the image base name. The directory and the base name constitute
68  // the constant part of the full filename
69  g.setBaseName("image");
70  // Set the step between two images of the sequence
71  g.setStep(3);
72  // Set the number of digits to build the image number
73  g.setNumberOfZero(4);
74  // Set the first frame number of the sequence
75  g.setImageNumber(1);
76  // Set the file extension of the images of the sequence
77  g.setExtension("pgm");
78 
79  // Open the framegrabber by loading the first image of the sequence
80  g.open(I) ;
81 
82  // this is the loop over the image sequence
83  for(int cpt = 0; cpt < 100; cpt++)
84  {
85  // read the image and then increment the image counter so that the next
86  // call to acquire(I) will get the next image
87  g.acquire(I) ;
88  }
89 
90  return 0;
91  }
92  catch(vpException &e) {
93  std::cout << "Catch an exception: " << e << std::endl;
94  return 1;
95  }
96 }
void setBaseName(const char *name)
error that can be emited by ViSP classes.
Definition: vpException.h:73
void setDirectory(const char *dir)
void setNumberOfZero(unsigned int noz)
void setStep(int a)
void setImageNumber(long number)
void open(vpImage< unsigned char > &I)
Class to grab (ie. read) images from the disk.
void setExtension(const char *ext)
void acquire(vpImage< unsigned char > &I)