ViSP  2.8.0
vp1394Grabber.h
1 /****************************************************************************
2  *
3  * $Id: vp1394Grabber.h 4323 2013-07-18 09:24:01Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Firewire cameras video capture.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
58 #ifndef vp1394Grabber_h
59 #define vp1394Grabber_h
60 
61 #include <visp/vpConfig.h>
62 
63 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
64 
65 #if defined(VISP_HAVE_DC1394_1)
66 
67 #include <string>
68 
69 #include <libraw1394/raw1394.h>
70 #include <libdc1394/dc1394_control.h>
71 
72 #include <visp/vpImage.h>
73 #include <visp/vpFrameGrabber.h>
74 #include <visp/vpRGBa.h>
75 #include <visp/vpList.h>
76 
77 
78 
123 class VISP_EXPORT vp1394Grabber : public vpFrameGrabber
124 {
125 public:
129  typedef enum {
133  RGB,
136  MONO16
137  } vp1394ImageFormatType;
138 
139  static const int DROP_FRAMES; // Number of frames to drop
140  static const int NUM_BUFFERS; // Number of buffers
141  static const int MAX_PORTS; // Port maximal number
142  static const int MAX_CAMERAS; // Maximal number of cameras on the bus
143 
144  static const char * strFormats[NUM_FORMATS];
145  static const char * strModesInFormat0[NUM_FORMAT0_MODES];
146  static const char * strModesInFormat1[NUM_FORMAT1_MODES];
147  static const char * strModesInFormat2[NUM_FORMAT2_MODES];
148  static const char * strModesInFormat6[NUM_FORMAT6_MODES];
149  static const char * strModesInFormat7[NUM_MODE_FORMAT7];
150  static const char * strColorsInFormat7[NUM_COLOR_FORMAT7];
151  static const char * strFramerates[NUM_FRAMERATES];
152 
153 
154 public:
155  vp_deprecated vp1394Grabber();
156  vp_deprecated vp1394Grabber(vpImage<unsigned char> &I);
157  virtual ~vp1394Grabber();
158 
159  void setCamera(unsigned int camera);
160  void getCamera(unsigned int &camera);
161 
162  void setFormat(int format);
163  void getFormat(int & format);
164  int getFormatSupported(vpList<int> & formats);
165 
166  void setMode(int mode);
167  void getMode(int & mode);
168  int getModeSupported(int format, vpList<int> & modes);
169 
170  void setFramerate(int framerate);
171  void getFramerate(int & framerate);
172  int getFramerateSupported(int format, int mode, vpList<int> & framerates);
173 
174  int convertFormat (std::string format);
175  int convertMode (std::string mode);
176  int convertFramerate(std::string framerate);
177 
178  std::string convertFormat (int format);
179  std::string convertMode (int mode);
180  std::string convertFramerate(int framerate);
181 
182  void setShutter(unsigned int shutter);
183  void getShutter(unsigned int &min_shutter,
184  unsigned int &shutter,
185  unsigned int &max_shutter);
186 
187  void setGain(unsigned int gain);
188  void getGain(unsigned int &min_gain,
189  unsigned int &gain,
190  unsigned int &max_gain);
191 
192  void open(vpImage<unsigned char> &I);
194  void open(vpImage<vpRGBa> &I);
195  void acquire(vpImage<vpRGBa> &I);
196  void close();
197 
198  void getWidth (unsigned int &width);
199  void getHeight(unsigned int &height);
200  void getNumCameras(unsigned int &cameras);
201 
202 
203 private:
204 
205  void open();
206  void setup();
207 
208  void getImageCharacteristics(int _format, int _mode,
209  int &width, int &height,
210  vp1394ImageFormatType &imageformat);
211  int* dmaCapture(bool waiting = true);
212  void dmaDoneWithBuffer();
213 
214  void startIsoTransmission();
215  void stopIsoTransmission();
216 
217 private:
218  bool iso_transmission_started;
219  bool handle_created;
220  bool camera_found;
221  bool camera_nodes_allocated;
222  bool dma_started;
223  unsigned int num_cameras;
224  /* declarations for libdc1394 */
225  raw1394handle_t *handles; // MAX_CAMERAS
226  dc1394_cameracapture *cameras; // MAX_CAMERAS
227  nodeid_t *camera_nodes;
228  dc1394_miscinfo miscinfo;
229  int *cam_count; // MAX_CAMERAS
230 
231  /* declarations for video1394 */
232  char device_name[FILENAME_MAX];
233 
234  unsigned int camera;
235  // Camera settings
236  int *pformat; // MAX_CAMERAS
237  int *pmode; // MAX_CAMERAS
238  int *pframerate; // MAX_CAMERAS
239  bool verbose;
240 
241  // Image settings
242  int *_width; // MAX_CAMERAS
243  int *_height; // MAX_CAMERAS
244  vp1394ImageFormatType *image_format; // MAX_CAMERAS
245 } ;
246 
247 #endif
248 #endif
249 #endif
Provide simple list management.
Definition: vpList.h:112
static const int MAX_PORTS
Class for firewire ieee1394 video devices using libdc1394-1.x api.
static const int DROP_FRAMES
virtual void open(vpImage< unsigned char > &I)=0
unsigned int getWidth() const
Return the number of columns in the image.
static const int MAX_CAMERAS
Base class for all video devices. It is designed to provide a front end to video sources.
virtual void close()=0
virtual void acquire(vpImage< unsigned char > &I)=0
unsigned int getHeight() const
Return the number of rows in the image.
static const int NUM_BUFFERS