ViSP  2.10.0
vp1394CMUGrabber.h
1 /****************************************************************************
2  *
3  * $Id: vp1394CMUGrabber.h 4574 2014-01-09 08:48:51Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 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 based on CMU 1394 Digital Camera SDK.
36  *
37  * Authors:
38  * Lucas Lopes Lemos FEMTO-ST, AS2M departement, Besancon
39  * Guillaume Laurent FEMTO-ST, AS2M departement, Besancon
40  * Fabien Spindler
41  *
42  *****************************************************************************/
43 
44 #ifndef vp1394CMUGrabber_h
45 #define vp1394CMUGrabber_h
46 
47 #include <visp/vpConfig.h>
48 
49 #ifdef VISP_HAVE_CMU1394
50 
51 #include <windows.h>
52 #include <1394Camera.h> // CMU library
53 
54 #include <visp/vpImage.h>
55 #include <visp/vpFrameGrabber.h>
56 #include <visp/vpFrameGrabberException.h>
57 #include <visp/vpRGBa.h>
58 
59 
147 class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber
148 {
149 public:
153  typedef enum {
160  UNKNOWN
161  } vpColorCodingType;
162 
163 private :
165  C1394Camera *camera;
167  int index;
169  unsigned long _format;
171  unsigned long _mode ;
173  unsigned long _fps ;
175  bool _modeauto;
177  unsigned short _gain;
179  unsigned short _shutter;
181  vpColorCodingType _color;
182 
183 public:
184 
185  // Constructor.
187  // Destructor.
188  virtual ~vp1394CMUGrabber();
189 
190  // Acquire one frame in a greyscale image.
192 
193  // Acquire one frame in a color image.
194  void acquire(vpImage<vpRGBa> &I);
195 
196  // Stop the acquisition.
197  void close();
198 
199  // Display information about the camera on the standard output.
200  void displayCameraDescription(int cam_id);
201 
202  // Display camera model on the standard output. Call it after open the grabber.
203  void displayCameraModel();
204 
205  // Get the video framerate
206  int getFramerate();
207 
208  // Get the gain min and max values.
209  void getGainMinMax(unsigned short &min, unsigned short &max);
210 
211  // Get the number of connected cameras.
212  int getNumberOfConnectedCameras() const ;
213 
214  // Get the shutter min and max values.
215  void getShutterMinMax(unsigned short &min, unsigned short &max);
216 
219  {
221  if (_format == 0)
222  {
223  switch(_mode)
224  {
225  case 0: color = vp1394CMUGrabber::YUV444; break;
226  case 1: color = vp1394CMUGrabber::YUV422; break;
227  case 2: color = vp1394CMUGrabber::YUV411; break;
228  case 3: color = vp1394CMUGrabber::YUV422; break;
229  case 4: color = vp1394CMUGrabber::RGB8; break;
230  case 5: color = vp1394CMUGrabber::MONO8; break;
231  case 6: color = vp1394CMUGrabber::MONO16; break;
232  }
233  }
234  else if (_format == 1)
235  {
236  switch(_mode)
237  {
238  case 0: color = vp1394CMUGrabber::YUV422; break;
239  case 1: color = vp1394CMUGrabber::RGB8; break;
240  case 2: color = vp1394CMUGrabber::MONO8; break;
241  case 3: color = vp1394CMUGrabber::YUV422; break;
242  case 4: color = vp1394CMUGrabber::RGB8; break;
243  case 5: color = vp1394CMUGrabber::MONO8; break;
244  case 6: color = vp1394CMUGrabber::MONO16; break;
245  case 7: color = vp1394CMUGrabber::MONO16; break;
246  }
247  }
248  else if (_format == 2)
249  {
250  switch(_mode)
251  {
252  case 0: color = vp1394CMUGrabber::YUV422; break;
253  case 1: color = vp1394CMUGrabber::RGB8; break;
254  case 2: color = vp1394CMUGrabber::MONO8; break;
255  case 3: color = vp1394CMUGrabber::YUV422; break;
256  case 4: color = vp1394CMUGrabber::RGB8; break;
257  case 5: color = vp1394CMUGrabber::MONO8; break;
258  case 6: color = vp1394CMUGrabber::MONO16; break;
259  case 7: color = vp1394CMUGrabber::MONO16; break;
260  }
261  }
262 
263  return color;
264  }
265 
266  // Initialization of the grabber using a greyscale image.
267  void open(vpImage<unsigned char> &I);
268 
269  // Initialization of the grabber using a color image.
270  void open(vpImage<vpRGBa> &I);
271 
272  // Select the camera on the bus. Call it before open the grabber.
273  void selectCamera(int cam_id);
274 
275  // Enable auto gain
276  void setAutoGain();
277 
278  // Enable auto shutter
279  void setAutoShutter();
280 
281  // Set the gain and the shutter values. Call it before open the grabber
282  void setControl(unsigned short gain, unsigned short shutter);
283 
284  // Set the frame rate. Call it before open the grabber.
285  void setFramerate(unsigned long fps);
286 
287  // Set the shutter value. Call it before open the grabber
288  void setShutter(unsigned short shutter);
289 
290  // Set the gain value. Call it before open the grabber
291  void setGain(unsigned short gain);
292 
293  // Set the video format and mode. Call it before open the grabber.
294  void setVideoMode(unsigned long format, unsigned long mode );
295 
296 private :
297 
298  void initCamera();
299 
300 };
301 
302 #endif
303 #endif
vpColorCodingType getVideoColorCoding() const
Get the video color coding format.
virtual void open(vpImage< unsigned char > &I)=0
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
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