This file is indexed.

/usr/include/visp/vpV4l2Grabber.h is in libvisp-dev 2.8.0-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/****************************************************************************
 *
 * $Id: vpV4l2Grabber.h 4323 2013-07-18 09:24:01Z fspindle $
 *
 * This file is part of the ViSP software.
 * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
 * 
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * ("GPL") version 2 as published by the Free Software Foundation.
 * See the file LICENSE.txt at the root directory of this source
 * distribution for additional information about the GNU GPL.
 *
 * For using ViSP with software that can not be combined with the GNU
 * GPL, please contact INRIA about acquiring a ViSP Professional 
 * Edition License.
 *
 * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
 * 
 * This software was developed at:
 * INRIA Rennes - Bretagne Atlantique
 * Campus Universitaire de Beaulieu
 * 35042 Rennes Cedex
 * France
 * http://www.irisa.fr/lagadic
 *
 * If you have questions regarding the use of this file, please contact
 * INRIA at visp@inria.fr
 * 
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * Description:
 * Video for linux two framegrabber.
 *
 * Authors:
 * Fabien Spindler
 *
 *****************************************************************************/


/*!
  \file vpV4l2Grabber.h
  \brief class for the Video For Linux 2 video device framegrabbing.
  \ingroup libdevice
*/

#ifndef vpV4l2Grabber_hh
#define vpV4l2Grabber_hh

#include <visp/vpConfig.h>

#ifdef VISP_HAVE_V4L2

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/videodev2.h> // Video For Linux Two interface
#include <libv4l2.h> // Video For Linux Two interface

#include <visp/vpImage.h>
#include <visp/vpFrameGrabber.h>
#include <visp/vpRGBa.h>




/*!
  \class vpV4l2Grabber

  \ingroup Framegrabber CameraDriver

  \brief Class for the Video4Linux2 video device.

  Information about Video4Linux can be found on
  http://linuxtv.org/v4lwiki/index.php/Main_Page

  This class was tested with a Pinnacle PCTV Studio/Rave board but
  also with the following webcams (Logitech QuickCam Vision Pro 9000,
  Logitech QuickCam Orbit AF, Dell latitude E6400 internal webcam).

  If the grabbing fail with a webcam, it means probably that you don't
  have the read/write permission on the /dev/video%%d device. You can
  set the right permissions by "sudo chmod a+rw /dev/video*".

  If the grabbing fails when the camera is attached to a bttv PCI
  card, it means potentially that you have not configured the linux
  bttv kernel module according to your board.
  
  For that, depending on your linux distribution check the card id in
  - /usr/share/doc/kernel-doc-2.4.20/video4linux/bttv/CARDLIST
  - or /usr/share/doc/kernel-doc-2.6.20/Documentation/video4linux/CARDLIST.bttv

  For example, the card id of a Pinnacle PCTV Studio/Rave board is 39.
  Once this id is determined, you have to set the bttv driver with, by adding
  \verbatim
  options bttv card=39
  \endverbatim
  in one of theses files :
  - /etc/modules.conf
  - or /etc/modprobe.conf

  This first example available in tutorial-grabber-v4l2.cpp shows how to grab
  and display images from an usb camera.
  \include tutorial-grabber-v4l2.cpp

  This other example shows how to use this grabber with an analogic camera
  attached to a bttv PCI card.
  \code
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpV4l2Grabber.h>
#include <visp/vpImageIo.h>

int main()
{
#if defined(VISP_HAVE_V4L2)
  vpImage<unsigned char> I;
  vpV4l2Grabber g;
  g.setInput(2);    // Input 2 on the board
  g.setFramerate(vpV4l2Grabber::framerate_25fps); //  25 fps
  g.setWidth(768);  // Acquired images are 768 width
  g.setHeight(576); // Acquired images are 576 height
  g.setNBuffers(3); // 3 ring buffers to ensure real-time acquisition
  g.open(I);        // Open the grabber

  g.acquire(I);     // Acquire a 768x576 grey image
  vpImageIo::write(I, "image.pgm"); // Save the image on the disk
#endif
}
  \endcode
  

  \author Fabien Spindler (Fabien.Spindler@irisa.fr), Irisa / Inria Rennes


  \sa vpFrameGrabber
*/
class VISP_EXPORT vpV4l2Grabber : public vpFrameGrabber
{
public:
  static const unsigned int DEFAULT_INPUT;
  static const unsigned int DEFAULT_SCALE;
  static const __u32 MAX_INPUTS;
  static const __u32 MAX_NORM;
  static const __u32 MAX_FORMAT;
  static const unsigned int MAX_CTRL;
  static const unsigned int MAX_BUFFERS;
  static const unsigned int FRAME_SIZE;

  /*! \enum vpV4l2FramerateType
    Frame rate type for capture.
  */
  typedef enum
    {
      framerate_50fps, //!< 50 frames per second
      framerate_25fps  //!< 25 frames per second
    } vpV4l2FramerateType;

  /*! \enum vpV4l2FrameFormatType
    Frame format type for capture.
  */
  typedef enum
    {
      V4L2_FRAME_FORMAT, /*!< a field only */
      V4L2_IMAGE_FORMAT  /*!< an interlaced image */
    } vpV4l2FrameFormatType;

  /*! \enum vpV4l2PixelFormatType
    Pixel format type for capture.
  */
  typedef enum {
    V4L2_GREY_FORMAT, /*!< 8  Greyscale */
    V4L2_RGB24_FORMAT, /*!< 24  RGB-8-8-8 */
    V4L2_RGB32_FORMAT, /*!< 32  RGB-8-8-8-8 */
    V4L2_BGR24_FORMAT, /*!< 24  BGR-8-8-8 */
    V4L2_YUYV_FORMAT, /*!< 16  YUYV 4:2:2  */
    V4L2_MAX_FORMAT
  } vpV4l2PixelFormatType;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  struct ng_video_fmt {
    unsigned int   pixelformat;         /* VIDEO_* */
    unsigned int   width;
    unsigned int   height;
    unsigned int   bytesperline;  /* zero for compressed formats */
  };


  struct ng_video_buf {
    struct ng_video_fmt  fmt;
    size_t               size;
    unsigned char        *data;
    int                  refcount;
  };
#endif

public:
  vpV4l2Grabber();
  vpV4l2Grabber(bool verbose);
  vpV4l2Grabber(unsigned input, unsigned scale = vpV4l2Grabber::DEFAULT_SCALE);
  vpV4l2Grabber(vpImage<unsigned char> &I,
		unsigned input, unsigned scale = vpV4l2Grabber::DEFAULT_SCALE);
  vpV4l2Grabber(vpImage<vpRGBa> &I,
		unsigned input, unsigned scale = vpV4l2Grabber::DEFAULT_SCALE);
  virtual ~vpV4l2Grabber() ;

public:
  void open(vpImage<unsigned char> &I) ;
  void open(vpImage<vpRGBa> &I) ;

  void acquire(vpImage<unsigned char> &I) ;
  void acquire(vpImage<unsigned char> &I, struct timeval &timestamp) ;
  void acquire(vpImage<vpRGBa> &I) ;
  void acquire(vpImage<vpRGBa> &I, struct timeval &timestamp) ;
  bool getField();
  vpV4l2FramerateType getFramerate();
  /*!

  Get the pixel format used for capture.

  \return Camera pixel format coding.

  */  
  inline vpV4l2PixelFormatType getPixelFormat() 
  {
    return (this->pixelformat);
  }
  /*!
    Activates the verbose mode to print additional information on stdout.
    \param verbose : If true activates the verbose mode.
  */
  void setVerboseMode(bool verbose) {
    this->verbose = verbose;
  };
  void setFramerate(vpV4l2FramerateType framerate);

  void setInput(unsigned input = vpV4l2Grabber::DEFAULT_INPUT) ;

  /*!
    Set image width to acquire.

  */
  inline void setWidth(unsigned width)
  {
    this->_width = width;
  }
  /*!
    Set image height to acquire.

  */
  inline void setHeight(unsigned height)
  {
    this->_height = height;
  }

  void setScale(unsigned scale = vpV4l2Grabber::DEFAULT_SCALE) ;

  /*!

  Set the number of buffers required for streaming data.

  For non real-time applications the number of buffers should be set to 1. For
  real-time applications to reach 25 fps or 50 fps a good compromise is to set
  the number of buffers to 3.

  \param nbuffers : Number of ring buffers.

  */
  inline void setNBuffers(unsigned nbuffers)
  {
    this->nbuffers = nbuffers;
  }

  /*!
    Set the device name.

    \param devname : Device name (like /dev/video0).

  */
  inline void setDevice(const char *devname)
  {
    sprintf(device, "%s", devname);
  }
  /*!

  Set the pixel format for capture.`If the specified pixel format is
  out of range, we set the V4L2_RGB24_FORMAT.

  \param pixelformat : Camera pixel format coding.

  */  
  inline void setPixelFormat(vpV4l2PixelFormatType pixelformat) 
  {
    this->pixelformat = pixelformat;
    if (this->pixelformat >= V4L2_MAX_FORMAT) 
      this->pixelformat = V4L2_RGB24_FORMAT;
  }

  void close();

private:
 
  void setFormat();
  /*!
    Set the frame format.

    \param frameformat :
    - vpV4l2Grabber::V4L2_FRAME_FORMAT: capture alternate fields (or frames),
    - vpV4l2Grabber::V4L2_IMAGE_FORMAT: capture interlaced images.
  */
  inline void setFrameFormat(vpV4l2FrameFormatType frameformat)
  {
    this->frameformat = frameformat;
  }
  void open();
  void getCapabilities();
  void startStreaming();
  void stopStreaming();
  unsigned char * waiton(__u32 &index, struct timeval &timestamp);
  int  queueBuffer();
  void queueAll();
  void printBufInfo(struct v4l2_buffer buf);


  int				fd;
  char				device[FILENAME_MAX];
  /* device descriptions */
  struct v4l2_capability	cap;
  struct v4l2_streamparm	streamparm;
  struct v4l2_input		*inp; //[vpV4l2Grabber::MAX_INPUTS];
  struct v4l2_standard      	*std; //[vpV4l2Grabber::MAX_NORM];
  struct v4l2_fmtdesc		*fmt; //[vpV4l2Grabber::MAX_FORMAT];
  struct v4l2_queryctrl		*ctl; //[vpV4l2Grabber::MAX_CTRL*2];

  /* capture */
  int                           fps;
  struct v4l2_format            fmt_v4l2;
  struct ng_video_fmt           fmt_me;
  struct v4l2_requestbuffers    reqbufs;
  struct v4l2_buffer            *buf_v4l2; //[vpV4l2Grabber::MAX_BUFFERS];
  struct ng_video_buf           *buf_me; //[vpV4l2Grabber::MAX_BUFFERS];
  unsigned int                  queue;
  unsigned int                  waiton_cpt;
  __u32				index_buffer; //!< index of the buffer in use

  bool		verbose;
  unsigned	nbuffers;
  unsigned int field;
  bool		streaming;

  unsigned      input;
  unsigned      _width;
  unsigned      _height;
  vpV4l2FramerateType framerate;
  vpV4l2FrameFormatType frameformat;
  vpV4l2PixelFormatType pixelformat;
} ;

#endif
#endif