Visual Servoing Platform  version 3.6.1 under development (2024-11-14)
vp1394CMUGrabber.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
33  *
34  * Authors:
35  * Lucas Lopes Lemos FEMTO-ST, AS2M departement, Besancon
36  * Guillaume Laurent FEMTO-ST, AS2M departement, Besancon
37  *
38 *****************************************************************************/
39 
45 #ifndef vp1394CMUGrabber_h
46 #define vp1394CMUGrabber_h
47 
48 #include <visp3/core/vpConfig.h>
49 
50 #ifdef VISP_HAVE_CMU1394
51 
52 // Include WinSock2.h before windows.h to ensure that winsock.h is not
53 // included by windows.h since winsock.h and winsock2.h are incompatible
54 #include <1394Camera.h> // CMU library
55 #include <WinSock2.h>
56 #include <windows.h>
57 
58 #include <visp3/core/vpFrameGrabber.h>
59 #include <visp3/core/vpFrameGrabberException.h>
60 #include <visp3/core/vpImage.h>
61 #include <visp3/core/vpRGBa.h>
62 
63 BEGIN_VISP_NAMESPACE
155 class VISP_EXPORT vp1394CMUGrabber : public vpFrameGrabber
156 {
157 public:
161  typedef enum { YUV444, YUV422, YUV411, RGB8, MONO8, MONO16, UNKNOWN } 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  // 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
202  // 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  switch (_mode) {
223  case 0:
224  color = vp1394CMUGrabber::YUV444;
225  break;
226  case 1:
227  color = vp1394CMUGrabber::YUV422;
228  break;
229  case 2:
230  color = vp1394CMUGrabber::YUV411;
231  break;
232  case 3:
233  color = vp1394CMUGrabber::YUV422;
234  break;
235  case 4:
236  color = vp1394CMUGrabber::RGB8;
237  break;
238  case 5:
239  color = vp1394CMUGrabber::MONO8;
240  break;
241  case 6:
242  color = vp1394CMUGrabber::MONO16;
243  break;
244  }
245  }
246  else if (_format == 1) {
247  switch (_mode) {
248  case 0:
249  color = vp1394CMUGrabber::YUV422;
250  break;
251  case 1:
252  color = vp1394CMUGrabber::RGB8;
253  break;
254  case 2:
255  color = vp1394CMUGrabber::MONO8;
256  break;
257  case 3:
258  color = vp1394CMUGrabber::YUV422;
259  break;
260  case 4:
261  color = vp1394CMUGrabber::RGB8;
262  break;
263  case 5:
264  color = vp1394CMUGrabber::MONO8;
265  break;
266  case 6:
267  color = vp1394CMUGrabber::MONO16;
268  break;
269  case 7:
270  color = vp1394CMUGrabber::MONO16;
271  break;
272  }
273  }
274  else if (_format == 2) {
275  switch (_mode) {
276  case 0:
277  color = vp1394CMUGrabber::YUV422;
278  break;
279  case 1:
280  color = vp1394CMUGrabber::RGB8;
281  break;
282  case 2:
283  color = vp1394CMUGrabber::MONO8;
284  break;
285  case 3:
286  color = vp1394CMUGrabber::YUV422;
287  break;
288  case 4:
289  color = vp1394CMUGrabber::RGB8;
290  break;
291  case 5:
292  color = vp1394CMUGrabber::MONO8;
293  break;
294  case 6:
295  color = vp1394CMUGrabber::MONO16;
296  break;
297  case 7:
298  color = vp1394CMUGrabber::MONO16;
299  break;
300  }
301  }
302 
303  return color;
304  }
305 
306  // Initialization of the grabber using a greyscale image.
307  void open(vpImage<unsigned char> &I);
308 
309  // Initialization of the grabber using a color image.
310  void open(vpImage<vpRGBa> &I);
311 
313  vp1394CMUGrabber &operator>>(vpImage<vpRGBa> &I);
314 
315  // Select the camera on the bus. Call it before open the grabber.
316  void selectCamera(int cam_id);
317 
318  // Enable auto gain
319  void setAutoGain();
320 
321  // Enable auto shutter
322  void setAutoShutter();
323 
324  // Set the gain and the shutter values. Call it before open the grabber
325  void setControl(unsigned short gain, unsigned short shutter);
326 
327  // Set the frame rate. Call it before open the grabber.
328  void setFramerate(unsigned long fps);
329 
330  // Set the shutter value. Call it before open the grabber
331  void setShutter(unsigned short shutter);
332 
333  // Set the gain value. Call it before open the grabber
334  void setGain(unsigned short gain);
335 
336  // Set the video format and mode. Call it before open the grabber.
337  void setVideoMode(unsigned long format, unsigned long mode);
338 
339 private:
340  void initCamera();
341 };
342 END_VISP_NAMESPACE
343 #endif
344 #endif
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
vpColorCodingType getVideoColorCoding() const
Get the video color coding format.
Base class for all video devices. It is designed to provide a front end to video sources.
virtual void open(vpImage< unsigned char > &I)=0
virtual void acquire(vpImage< unsigned char > &I)=0
virtual void close()=0