Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vp1394CMUGrabber.h
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  * 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 
146 class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber
147 {
148 public:
152  typedef enum {
159  UNKNOWN
160  } vpColorCodingType;
161 
162 private :
164  C1394Camera *camera;
166  int index;
168  unsigned long _format;
170  unsigned long _mode ;
172  unsigned long _fps ;
174  bool _modeauto;
176  unsigned short _gain;
178  unsigned short _shutter;
180  vpColorCodingType _color;
181 
182 public:
183 
184  // Constructor.
186  // Destructor.
187  virtual ~vp1394CMUGrabber();
188 
189  // Acquire one frame in a greyscale image.
191 
192  // Acquire one frame in a color image.
193  void acquire(vpImage<vpRGBa> &I);
194 
195  // Stop the acquisition.
196  void close();
197 
198  // Display information about the camera on the standard output.
199  void displayCameraDescription(int cam_id);
200 
201  // Display camera model on the standard output. Call it after open the grabber.
202  void displayCameraModel();
203 
204  // Get the video framerate
205  int getFramerate();
206 
207  // Get the gain min and max values.
208  void getGainMinMax(unsigned short &min, unsigned short &max);
209 
210  // Get the number of connected cameras.
211  int getNumberOfConnectedCameras() const ;
212 
213  // Get the shutter min and max values.
214  void getShutterMinMax(unsigned short &min, unsigned short &max);
215 
218  {
220  if (_format == 0)
221  {
222  switch(_mode)
223  {
224  case 0: color = vp1394CMUGrabber::YUV444; break;
225  case 1: color = vp1394CMUGrabber::YUV422; break;
226  case 2: color = vp1394CMUGrabber::YUV411; break;
227  case 3: color = vp1394CMUGrabber::YUV422; break;
228  case 4: color = vp1394CMUGrabber::RGB8; break;
229  case 5: color = vp1394CMUGrabber::MONO8; break;
230  case 6: color = vp1394CMUGrabber::MONO16; break;
231  }
232  }
233  else if (_format == 1)
234  {
235  switch(_mode)
236  {
237  case 0: color = vp1394CMUGrabber::YUV422; break;
238  case 1: color = vp1394CMUGrabber::RGB8; break;
239  case 2: color = vp1394CMUGrabber::MONO8; break;
240  case 3: color = vp1394CMUGrabber::YUV422; break;
241  case 4: color = vp1394CMUGrabber::RGB8; break;
242  case 5: color = vp1394CMUGrabber::MONO8; break;
243  case 6: color = vp1394CMUGrabber::MONO16; break;
244  case 7: color = vp1394CMUGrabber::MONO16; break;
245  }
246  }
247  else if (_format == 2)
248  {
249  switch(_mode)
250  {
251  case 0: color = vp1394CMUGrabber::YUV422; break;
252  case 1: color = vp1394CMUGrabber::RGB8; break;
253  case 2: color = vp1394CMUGrabber::MONO8; break;
254  case 3: color = vp1394CMUGrabber::YUV422; break;
255  case 4: color = vp1394CMUGrabber::RGB8; break;
256  case 5: color = vp1394CMUGrabber::MONO8; break;
257  case 6: color = vp1394CMUGrabber::MONO16; break;
258  case 7: color = vp1394CMUGrabber::MONO16; break;
259  }
260  }
261 
262  return color;
263  }
264 
265  // Initialization of the grabber using a greyscale image.
266  void open(vpImage<unsigned char> &I);
267 
268  // Initialization of the grabber using a color image.
269  void open(vpImage<vpRGBa> &I);
270 
271  vp1394CMUGrabber & operator>>(vpImage<unsigned char> &I);
272  vp1394CMUGrabber & operator>>(vpImage<vpRGBa> &I);
273 
274  // Select the camera on the bus. Call it before open the grabber.
275  void selectCamera(int cam_id);
276 
277  // Enable auto gain
278  void setAutoGain();
279 
280  // Enable auto shutter
281  void setAutoShutter();
282 
283  // Set the gain and the shutter values. Call it before open the grabber
284  void setControl(unsigned short gain, unsigned short shutter);
285 
286  // Set the frame rate. Call it before open the grabber.
287  void setFramerate(unsigned long fps);
288 
289  // Set the shutter value. Call it before open the grabber
290  void setShutter(unsigned short shutter);
291 
292  // Set the gain value. Call it before open the grabber
293  void setGain(unsigned short gain);
294 
295  // Set the video format and mode. Call it before open the grabber.
296  void setVideoMode(unsigned long format, unsigned long mode );
297 
298 private :
299 
300  void initCamera();
301 
302 };
303 
304 #endif
305 #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