ViSP  2.7.0
vp1394CMUGrabber.h
1 /****************************************************************************
2  *
3  * $Id: vp1394CMUGrabber.h 4056 2013-01-05 13:04:42Z 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 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 
182 class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber
183 {
184 public:
188  typedef enum {
195  UNKNOWN
196  } vpColorCodingType;
197 
198 private :
200  C1394Camera *camera;
202  int index;
204  unsigned long _format;
206  unsigned long _mode ;
208  unsigned long _fps ;
210  bool _modeauto;
212  unsigned short _gain;
214  unsigned short _shutter;
216  vpColorCodingType _color;
217 
218 public:
219 
220  // Constructor.
222  // Destructor.
223  virtual ~vp1394CMUGrabber();
224 
225  // Initialization of the grabber using a greyscale image.
226  void open(vpImage<unsigned char> &I);
227 
228  // Initialization of the grabber using a color image.
229  void open(vpImage<vpRGBa> &I);
230 
231  // Acquire one frame in a greyscale image.
233 
234  // Acquire one frame in a color image.
235  void acquire(vpImage<vpRGBa> &I);
236 
237  // Stop the acquisition.
238  void close();
239 
240  // Display information about the camera on the standard output.
241  void displayCameraDescription(int cam_id);
242 
243  // Display camera model on the standard output. Call it after open the grabber.
244  void displayCameraModel();
245 
246  // Get the number of connected cameras.
247  int getNumberOfConnectedCameras() const ;
248 
251  {
253  if (_format == 0)
254  {
255  switch(_mode)
256  {
257  case 0: color = vp1394CMUGrabber::YUV444; break;
258  case 1: color = vp1394CMUGrabber::YUV422; break;
259  case 2: color = vp1394CMUGrabber::YUV411; break;
260  case 3: color = vp1394CMUGrabber::YUV422; break;
261  case 4: color = vp1394CMUGrabber::RGB8; break;
262  case 5: color = vp1394CMUGrabber::MONO8; break;
263  case 6: color = vp1394CMUGrabber::MONO16; break;
264  }
265  }
266  else if (_format == 1)
267  {
268  switch(_mode)
269  {
270  case 0: color = vp1394CMUGrabber::YUV422; break;
271  case 1: color = vp1394CMUGrabber::RGB8; break;
272  case 2: color = vp1394CMUGrabber::MONO8; break;
273  case 3: color = vp1394CMUGrabber::YUV422; break;
274  case 4: color = vp1394CMUGrabber::RGB8; break;
275  case 5: color = vp1394CMUGrabber::MONO8; break;
276  case 6: color = vp1394CMUGrabber::MONO16; break;
277  case 7: color = vp1394CMUGrabber::MONO16; break;
278  }
279  }
280  else if (_format == 2)
281  {
282  switch(_mode)
283  {
284  case 0: color = vp1394CMUGrabber::YUV422; break;
285  case 1: color = vp1394CMUGrabber::RGB8; break;
286  case 2: color = vp1394CMUGrabber::MONO8; break;
287  case 3: color = vp1394CMUGrabber::YUV422; break;
288  case 4: color = vp1394CMUGrabber::RGB8; break;
289  case 5: color = vp1394CMUGrabber::MONO8; break;
290  case 6: color = vp1394CMUGrabber::MONO16; break;
291  case 7: color = vp1394CMUGrabber::MONO16; break;
292  }
293  }
294 
295  return color;
296 
297  }
298 
299  // Select the camera on the bus. Call it before open the grabber.
300  void selectCamera(int cam_id);
301 
302  // Set the gain and the shutter values. Call it before open the grabber
303  void setControl(unsigned short gain , unsigned short shutter) ;
304 
305  // Set the frame rate. Call it before open the grabber.
306  void setFramerate(unsigned long fps);
307 
308  // Set the video format and mode. Call it before open the grabber.
309  void setVideoMode(unsigned long format , unsigned long mode );
310 
311 private :
312 
313  void initCamera();
314 
315 };
316 
317 #endif
318 #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