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