Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpV4l2Grabber Class Reference

#include <visp3/sensor/vpV4l2Grabber.h>

+ Inheritance diagram for vpV4l2Grabber:

Public Types

enum  vpV4l2FramerateType { framerate_50fps, framerate_25fps }
 
enum  vpV4l2FrameFormatType { V4L2_FRAME_FORMAT, V4L2_IMAGE_FORMAT }
 
enum  vpV4l2PixelFormatType {
  V4L2_GREY_FORMAT, V4L2_RGB24_FORMAT, V4L2_RGB32_FORMAT, V4L2_BGR24_FORMAT,
  V4L2_YUYV_FORMAT, V4L2_MAX_FORMAT
}
 

Public Member Functions

 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 ()
 
void open (vpImage< unsigned char > &I)
 
void open (vpImage< vpRGBa > &I)
 
void acquire (vpImage< unsigned char > &I)
 
void acquire (vpImage< unsigned char > &I, const vpRect &roi)
 
void acquire (vpImage< unsigned char > &I, struct timeval &timestamp, const vpRect &roi=vpRect())
 
void acquire (vpImage< vpRGBa > &I)
 
void acquire (vpImage< vpRGBa > &I, const vpRect &roi)
 
void acquire (vpImage< vpRGBa > &I, struct timeval &timestamp, const vpRect &roi=vpRect())
 
bool getField ()
 
vpV4l2FramerateType getFramerate ()
 
vpV4l2PixelFormatType getPixelFormat ()
 
vpV4l2Grabberoperator>> (vpImage< unsigned char > &I)
 
vpV4l2Grabberoperator>> (vpImage< vpRGBa > &I)
 
void setVerboseMode (bool verbose)
 
void setFramerate (vpV4l2FramerateType framerate)
 
void setInput (unsigned input=vpV4l2Grabber::DEFAULT_INPUT)
 
void setWidth (unsigned w)
 
void setHeight (unsigned h)
 
void setScale (unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
 
void setNBuffers (unsigned nbuffers)
 
void setDevice (const std::string &devname)
 
void setPixelFormat (vpV4l2PixelFormatType pixelformat)
 
void close ()
 
Inherited functionalities from vpFramegrabber
unsigned int getHeight () const
 
unsigned int getWidth () const
 

Public Attributes

bool init
 

Static Public Attributes

static const unsigned int DEFAULT_INPUT = 2
 
static const unsigned int DEFAULT_SCALE = 2
 
static const __u32 MAX_INPUTS = 16
 
static const __u32 MAX_NORM = 16
 
static const __u32 MAX_FORMAT = 32
 
static const unsigned int MAX_CTRL = 32
 
static const unsigned int MAX_BUFFERS = 32
 
static const unsigned int FRAME_SIZE = 288
 

Protected Attributes

unsigned int height
 
unsigned int width
 

Detailed Description

Class that is a wrapper over the Video4Linux2 (V4L2) driver.

Thus to be enabled, this class needs the optional V4L2 3rd party. Installation instruction are provided here https://visp.inria.fr/3rd_v4l2.

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, Logitech QuickCam IM (V-USB39), 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

  options bttv card=39

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 <visp3/core/vpImage.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/sensor/vpV4l2Grabber.h>
#include <visp3/io/vpImageStorageWorker.h>
//#define USE_COLOR // Comment to acquire gray level images
int main(int argc, const char *argv[])
{
#if defined(VISP_HAVE_V4L2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
try {
int opt_device = 0;
unsigned int opt_scale = 1; // Default value is 2 in the constructor. Turn
// it to 1 to avoid subsampling
std::string opt_seqname;
int opt_record_mode = 0;
for (int i = 0; i < argc; i++) {
if (std::string(argv[i]) == "--camera_device")
opt_device = std::atoi(argv[i + 1]);
else if (std::string(argv[i]) == "--scale")
opt_scale = (unsigned int)atoi(argv[i + 1]);
else if (std::string(argv[i]) == "--seqname")
opt_seqname = std::string(argv[i + 1]);
else if (std::string(argv[i]) == "--record")
opt_record_mode = std::atoi(argv[i + 1]);
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
std::cout << "\nUsage: " << argv[0]
<< " [--camera_device <camera device (default: 0)>] [--scale <subsampling factor (default: 1)>]"
" [--seqname <sequence name (default: empty>] [--record <0: continuous | 1: single shot (default: 0)>]"
" [--help] [-h]\n"
<< "\nExample to visualize images:\n"
<< " " << argv[0] << "\n"
<< "\nExample to visualize images from a second camera:\n"
<< " " << argv[0] << " --camera_device 1\n"
<< "\nExamples to record a sequence:\n"
<< " " << argv[0] << " --seqname I%04d.png \n"
<< " " << argv[0] << " --seqname folder/I%04d.png --record 0\n"
<< "\nExamples to record single shot images:\n"
<< " " << argv[0] << " --seqname I%04d.png --record 1\n"
<< " " << argv[0] << " --seqname folder/I%04d.png --record 1\n"
<< std::endl;
return 0;
}
}
std::cout << "Use device : " << opt_device << std::endl;
std::cout << "Recording : " << (opt_seqname.empty() ? "disabled" : "enabled") << std::endl;
std::string text_record_mode = std::string("Record mode: ") + (opt_record_mode ? std::string("single") : std::string("continuous"));
if (! opt_seqname.empty()) {
std::cout << text_record_mode << std::endl;
std::cout << "Record name: " << opt_seqname << std::endl;
}
#ifdef USE_COLOR
vpImage<vpRGBa> I; // To acquire color images
#else
vpImage<unsigned char> I; // To acquire gray images
#endif
std::ostringstream device;
device << "/dev/video" << opt_device;
g.setDevice(device.str());
g.setScale(opt_scale);
g.open(I);
std::cout << "Image size : " << I.getWidth() << " " << I.getHeight() << std::endl;
#ifdef VISP_HAVE_X11
vpDisplayX d(I);
#elif defined(VISP_HAVE_OPENCV)
#else
std::cout << "No image viewer is available..." << std::endl;
#endif
#ifdef USE_COLOR
vpImageQueue<vpRGBa> image_queue(opt_seqname, opt_record_mode);
vpImageStorageWorker<vpRGBa> image_storage_worker(std::ref(image_queue));
std::thread image_storage_thread(&vpImageStorageWorker<vpRGBa>::run, &image_storage_worker);
#else
vpImageQueue<unsigned char> image_queue(opt_seqname, opt_record_mode);
vpImageStorageWorker<unsigned char> image_storage_worker(std::ref(image_queue));
std::thread image_storage_thread(&vpImageStorageWorker<unsigned char>::run, &image_storage_worker);
#endif
bool quit = false;
while (! quit) {
double t = vpTime::measureTimeMs();
g.acquire(I);
quit = image_queue.record(I);
std::stringstream ss;
ss << "Acquisition time: " << std::setprecision(3) << vpTime::measureTimeMs() - t << " ms";
vpDisplay::displayText(I, I.getHeight() - 20, 10, ss.str(), vpColor::red);
}
image_queue.cancel();
image_storage_thread.join();
} catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#else
(void) argc;
(void) argv;
#ifndef VISP_HAVE_V4L2
std::cout << "Install Video 4 Linux 2 (v4l2), configure and build ViSP again to use this example" << std::endl;
#endif
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
std::cout << "This turorial should be built with c++11 support" << std::endl;
#endif
#endif
}

This other example shows how to use this grabber with an analogic camera attached to a bttv PCI card.

#include <visp3/io/vpImageIo.h>
#include <visp3/sensor/vpV4l2Grabber.h>
int main()
{
#if defined(VISP_HAVE_V4L2)
g.setInput(2); // Input 2 on the board
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
}
Author
Fabien Spindler (Fabie.nosp@m.n.Sp.nosp@m.indle.nosp@m.r@ir.nosp@m.isa.f.nosp@m.r), Irisa / Inria Rennes
See also
vpFrameGrabber
Examples:
grabV4l2.cpp, grabV4l2MultiCpp11Thread.cpp, HelloWorldOgre.cpp, HelloWorldOgreAdvanced.cpp, manGrabV4l2.cpp, mbot-apriltag-2D-half-vs.cpp, mbot-apriltag-ibvs.cpp, mbot-apriltag-pbvs.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, servoPioneerPoint2DDepthWithoutVpServo.cpp, tutorial-apriltag-detector-live.cpp, tutorial-barcode-detector-live.cpp, tutorial-blob-tracker-live-v4l2.cpp, tutorial-face-detector-live-threaded.cpp, tutorial-face-detector-live.cpp, tutorial-grabber-v4l2-threaded.cpp, tutorial-grabber-v4l2.cpp, tutorial-klt-tracker-live-v4l2.cpp, tutorial-mb-generic-tracker-apriltag-webcam.cpp, tutorial-mb-generic-tracker-live.cpp, tutorial-me-ellipse-tracker.cpp, tutorial-me-line-tracker.cpp, tutorial-pose-from-points-live.cpp, and tutorial-video-recorder.cpp.

Definition at line 134 of file vpV4l2Grabber.h.

Member Enumeration Documentation

◆ vpV4l2FrameFormatType

Frame format type for capture.

Enumerator
V4L2_FRAME_FORMAT 

a field only

V4L2_IMAGE_FORMAT 

an interlaced image

Definition at line 157 of file vpV4l2Grabber.h.

◆ vpV4l2FramerateType

Frame rate type for capture.

Enumerator
framerate_50fps 

50 frames per second

framerate_25fps 

25 frames per second

Definition at line 149 of file vpV4l2Grabber.h.

◆ vpV4l2PixelFormatType

Pixel format type for capture.

Enumerator
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 
Examples:
grabV4l2.cpp.

Definition at line 165 of file vpV4l2Grabber.h.

Constructor & Destructor Documentation

◆ vpV4l2Grabber() [1/5]

vpV4l2Grabber::vpV4l2Grabber ( )

Default constructor.

Setup the Video For Linux Two (V4L2) driver in streaming mode.

Default settings are:

vpImage<unsigned char> I; // Grey level image
g.setInput(2); // Input 2 on the board
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

The grabber allows also to grab a portion of an image using a region of interest. The following example shows how to grab a 320x240 region located on the top/left corner of the image that has a higher resolution (ie 640x480).

#include <visp3/gui/vpDisplayX.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/sensor/vpV4l2Grabber.h>
int main()
{
#if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_X11)
vpRect roi(0, 0, 320, 240); // specify the region to crop
bool first = true;
while (1) {
g.acquire(I, roi);
if(first) {
d = new vpDisplayX(I);
first = false;
}
if (vpDisplay::getClick(I, false))
break;
}
vpImageIo::write(I, "image.pgm"); // Save the last image
delete d;
#endif

Definition at line 149 of file vpV4l2Grabber.cpp.

References DEFAULT_INPUT, DEFAULT_SCALE, framerate_25fps, vpFrameGrabber::init, setDevice(), setFramerate(), setInput(), setNBuffers(), setPixelFormat(), setScale(), and V4L2_YUYV_FORMAT.

◆ vpV4l2Grabber() [2/5]

vpV4l2Grabber::vpV4l2Grabber ( bool  verbose)
explicit

Default constructor.

Setup the Video For Linux Two (V4L2) driver in streaming mode.

Parameters
verbose: If true activates the verbose mode.

Default settings are:

  • Device name: /dev/video0: To change it use setDevice()
  • Number of ring buffers: 3. To change this value use setNBuffers(). 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.
  • Framerate acquisition: 25 fps. Use setFramerate() to set 25 fps or 50 fps. These framerates are reachable only if enought buffers are set.
  • Input board: vpV4l2Grabber::DEFAULT_INPUT. Video input port. Use setInput() to change it.
  • Image size acquisition: vpV4l2Grabber::DEFAULT_SCALE. Use either setScale() or setWidth() and setHeight to change it.
vpImage<unsigned char> I; // Grey level image
vpV4l2Grabber g(true); // Activates the verbose mode
g.setInput(2); // Input 2 on the board
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

Definition at line 205 of file vpV4l2Grabber.cpp.

References DEFAULT_INPUT, DEFAULT_SCALE, framerate_25fps, vpFrameGrabber::init, setDevice(), setFramerate(), setInput(), setNBuffers(), setPixelFormat(), setScale(), and V4L2_YUYV_FORMAT.

◆ vpV4l2Grabber() [3/5]

vpV4l2Grabber::vpV4l2Grabber ( unsigned  input,
unsigned  scale = vpV4l2Grabber::DEFAULT_SCALE 
)

Constructor.

Setup the Video For Linux Two (V4L2) driver in streaming mode.

Parameters
input: Video input port.
scale: Decimation factor.

Default settings are:

  • Device name: /dev/video0: To change it use setDevice()
  • Number of ring buffers: 3. To change this value use setNBuffers(). 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.
  • Framerate acquisition: 25 fps. Use setFramerate() to set 25 fps or 50 fps. These framerates are reachable only if enought buffers are set.
vpImage<unsigned char> I; // Grey level image
vpV4l2Grabber g(1, 2); // Select input 1, and half full size resolution images.
g.open(I); // Open the grabber
g.acquire(I); // Acquire a 384x288 grey image

Definition at line 251 of file vpV4l2Grabber.cpp.

References framerate_25fps, vpFrameGrabber::init, setDevice(), setFramerate(), setInput(), setNBuffers(), and setScale().

◆ vpV4l2Grabber() [4/5]

vpV4l2Grabber::vpV4l2Grabber ( vpImage< unsigned char > &  I,
unsigned  input,
unsigned  scale = vpV4l2Grabber::DEFAULT_SCALE 
)

Constructor.

Setup the Video For Linux Two (V4L2) driver in streaming mode.

Parameters
I: Image data structure (grey 8 bits image)
input: Video input port.
scale: Decimation factor.

Default settings are:

  • Device name: /dev/video0: To change it use setDevice()
  • Number of ring buffers: 3. To change this value use setNBuffers(). 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.
  • Framerate acquisition: 25 fps. Use setFramerate() to set 25 fps or 50 fps. These framerates are reachable only if enought buffers are set.
vpImage<unsigned char> I; // Grey level image
vpV4l2Grabber g(I, 1, 2); // Select input 1, and half full size resolution
// images and open the grabber
g.acquire(I); // Acquire a 384x288 grey image

Definition at line 297 of file vpV4l2Grabber.cpp.

References framerate_25fps, vpFrameGrabber::init, open(), setDevice(), setFramerate(), setInput(), setNBuffers(), and setScale().

◆ vpV4l2Grabber() [5/5]

vpV4l2Grabber::vpV4l2Grabber ( vpImage< vpRGBa > &  I,
unsigned  input,
unsigned  scale = vpV4l2Grabber::DEFAULT_SCALE 
)

Constructor.

Setup the Video For Linux Two (V4L2) driver in streaming mode.

Parameters
I: Image data structure (Color RGB32 bits image)
input: Video input port.
scale: Decimation factor.

Default settings are:

  • Device name: /dev/video0: To change it use setDevice()
  • Number of ring buffers: 3. To change this value use setNBuffers(). 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.
  • Framerate acquisition: 25 fps. Use setFramerate() to set 25 fps or 50 fps. These framerates are reachable only if enought buffers are set.
vpImage<vpRGBa> I; // Color image
vpV4l2Grabber g(I, 1, 2); // Select input 1, and half full size resolution
// images and open the grabber
g.acquire(I); // Acquire a 384x288 color image

Definition at line 346 of file vpV4l2Grabber.cpp.

References framerate_25fps, vpFrameGrabber::init, open(), setDevice(), setFramerate(), setInput(), setNBuffers(), and setScale().

◆ ~vpV4l2Grabber()

vpV4l2Grabber::~vpV4l2Grabber ( )
virtual

Destructor.

See also
close()

Definition at line 368 of file vpV4l2Grabber.cpp.

References close().

Member Function Documentation

◆ acquire() [1/6]

◆ acquire() [2/6]

void vpV4l2Grabber::acquire ( vpImage< unsigned char > &  I,
const vpRect roi 
)

Acquire a grey level image.

Parameters
I: Image data structure (8 bits image)
roi: Region of interest to grab from the full resolution image.
Exceptions
vpFrameGrabberException::initializationError: Frame grabber not initialized.
See also
getField()

Definition at line 545 of file vpV4l2Grabber.cpp.

References acquire().

◆ acquire() [3/6]

void vpV4l2Grabber::acquire ( vpImage< unsigned char > &  I,
struct timeval &  timestamp,
const vpRect roi = vpRect() 
)

Acquire a grey level image.

Parameters
I: Image data structure (8 bits image).
timestamp: Timeval data structure providing the unix time at which the frame was captured in the ringbuffer. Warning: some v4l2 drivers do not return the time since 1970 (the one returned by gettimeofday() or vpTime) but rather a time that counts from the boot time (i.e. uptime).
roi: Region of interest to grab from the full resolution image. By default acquire the whole image.
Exceptions
vpFrameGrabberException::initializationError: Frame grabber not initialized.
See also
getField()

Definition at line 571 of file vpV4l2Grabber.cpp.

References vpImageConvert::BGRToGrey(), vpImage< Type >::bitmap, close(), vpImageTools::crop(), vpRect::getHeight(), vpRect::getWidth(), vpFrameGrabber::height, vpFrameGrabber::init, vpFrameGrabberException::initializationError, open(), vpImage< Type >::resize(), vpImageConvert::RGBaToGrey(), vpImageConvert::RGBToGrey(), V4L2_BGR24_FORMAT, V4L2_GREY_FORMAT, V4L2_RGB24_FORMAT, V4L2_RGB32_FORMAT, V4L2_YUYV_FORMAT, vpFrameGrabber::width, and vpImageConvert::YUYVToGrey().

◆ acquire() [4/6]

void vpV4l2Grabber::acquire ( vpImage< vpRGBa > &  I)
virtual

Acquire a color image.

Parameters
I: Image data structure (32 bits image)
Exceptions
vpFrameGrabberException::initializationError: Frame grabber not initialized.
See also
getField()

Implements vpFrameGrabber.

Definition at line 652 of file vpV4l2Grabber.cpp.

References acquire().

◆ acquire() [5/6]

void vpV4l2Grabber::acquire ( vpImage< vpRGBa > &  I,
const vpRect roi 
)

Acquire a color image.

Parameters
I: Image data structure (32 bits image)
roi: Region of interest to grab from the full resolution image.
Exceptions
vpFrameGrabberException::initializationError: Frame grabber not initialized.
See also
getField()

Definition at line 671 of file vpV4l2Grabber.cpp.

References acquire().

◆ acquire() [6/6]

void vpV4l2Grabber::acquire ( vpImage< vpRGBa > &  I,
struct timeval &  timestamp,
const vpRect roi = vpRect() 
)

Acquire a color image.

Parameters
I: Image data structure (32 bits image).
timestamp: Timeval data structure providing the unix time at which the frame was captured in the ringbuffer. Warning: some v4l2 drivers do not return the time since 1970 (the one returned by gettimeofday() or vpTime) but rather a time that counts from the boot time (i.e. uptime).
roi: Region of interest to grab from the full resolution image. By default acquire the whole image.
Exceptions
vpFrameGrabberException::initializationError: Frame grabber not initialized.
See also
getField()

Definition at line 697 of file vpV4l2Grabber.cpp.

References vpImageConvert::BGRToRGBa(), vpImage< Type >::bitmap, close(), vpImageTools::crop(), vpRect::getHeight(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getTop(), vpRect::getWidth(), vpImage< Type >::getWidth(), vpImageConvert::GreyToRGBa(), vpFrameGrabber::height, vpFrameGrabber::init, vpFrameGrabberException::initializationError, open(), vpImage< Type >::resize(), vpImageConvert::RGBToRGBa(), V4L2_BGR24_FORMAT, V4L2_GREY_FORMAT, V4L2_RGB24_FORMAT, V4L2_RGB32_FORMAT, V4L2_YUYV_FORMAT, vpFrameGrabber::width, and vpImageConvert::YUYVToRGBa().

◆ close()

◆ getField()

bool vpV4l2Grabber::getField ( )

Return the field (odd or even) corresponding to the last acquired frame.

This method is to call after acquire() and has only a mean if the acquisition framerate is set to 50 fps.

Returns
Field of the acquired frame (0 if odd field, 1 if even field).
Exceptions
vpFrameGrabberException::otherError: Video device returns a bad frame field.
See also
acquire(), setFramerate()

Definition at line 791 of file vpV4l2Grabber.cpp.

References close(), and vpFrameGrabberException::otherError.

◆ getFramerate()

vpV4l2Grabber::vpV4l2FramerateType vpV4l2Grabber::getFramerate ( )

Return the framerate of the acquisition.

Returns
The actual framerate of the framegrabber.
See also
setFramerate()

Definition at line 837 of file vpV4l2Grabber.cpp.

◆ getHeight()

unsigned int vpFrameGrabber::getHeight ( ) const
inlineinherited

Return the number of rows in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, and testPylonGrabber.cpp.

Definition at line 114 of file vpFrameGrabber.h.

◆ getPixelFormat()

vpV4l2PixelFormatType vpV4l2Grabber::getPixelFormat ( )
inline

Get the pixel format used for capture.

Returns
Camera pixel format coding.

Definition at line 239 of file vpV4l2Grabber.h.

Referenced by open().

◆ getWidth()

unsigned int vpFrameGrabber::getWidth ( ) const
inlineinherited

Return the number of columns in the image.

Examples:
AROgre.cpp, AROgreBasic.cpp, and testPylonGrabber.cpp.

Definition at line 116 of file vpFrameGrabber.h.

◆ open() [1/2]

◆ open() [2/2]

void vpV4l2Grabber::open ( vpImage< vpRGBa > &  I)
virtual

Initialize image acquisition in color RGB32 format. Set the pixel format acquisition to vpV4l2Grabber::V4L2_RGB32_FORMAT.

Parameters
I: Image data structure (RGB32 bits image). Once the device is open, the image is resized to the current acquisition size.

Implements vpFrameGrabber.

Definition at line 471 of file vpV4l2Grabber.cpp.

References getPixelFormat(), vpFrameGrabber::height, vpFrameGrabber::init, open(), vpImage< Type >::resize(), setPixelFormat(), V4L2_MAX_FORMAT, and vpFrameGrabber::width.

◆ operator>>() [1/2]

vpV4l2Grabber & vpV4l2Grabber::operator>> ( vpImage< unsigned char > &  I)

Operator that allows to capture a grey level image.

Parameters
I: The captured image.
#include <visp3/sensor/vpV4l2Grabber.h>
int main()
{
g >> I;
}

Definition at line 1455 of file vpV4l2Grabber.cpp.

References acquire().

◆ operator>>() [2/2]

vpV4l2Grabber & vpV4l2Grabber::operator>> ( vpImage< vpRGBa > &  I)

Operator that allows to capture a grey level image.

Parameters
I: The captured image.
#include <visp3/sensor/vpV4l2Grabber.h>
int main()
{
g >> I;
}

Definition at line 1477 of file vpV4l2Grabber.cpp.

References acquire().

◆ setDevice()

◆ setFramerate()

void vpV4l2Grabber::setFramerate ( vpV4l2Grabber::vpV4l2FramerateType  framerate)

Set the frame format depending on the framerate acquisition.

Parameters
framerate: The framerate for the acquisition.
Warning
If you want to acquire frames at 25 fps or 50 fps, you have to be aware of the number of buffers required for the streaming. A typical value could be 3 (see setNBuffers()).
See also
getFramerate(), setNBuffers()
Examples:
grabV4l2.cpp.

Definition at line 818 of file vpV4l2Grabber.cpp.

References framerate_25fps, V4L2_FRAME_FORMAT, and V4L2_IMAGE_FORMAT.

Referenced by vpV4l2Grabber().

◆ setHeight()

void vpV4l2Grabber::setHeight ( unsigned  h)
inline

Set image height to acquire.

Examples:
manGrabV4l2.cpp.

Definition at line 262 of file vpV4l2Grabber.h.

References DEFAULT_SCALE.

Referenced by setScale().

◆ setInput()

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

Set the video input port on the board.

Examples:
grabV4l2.cpp, manGrabV4l2.cpp, servoPioneerPanSegment3D.cpp, servoPioneerPoint2DDepth.cpp, and servoPioneerPoint2DDepthWithoutVpServo.cpp.

Definition at line 373 of file vpV4l2Grabber.cpp.

Referenced by vpV4l2Grabber().

◆ setNBuffers()

void vpV4l2Grabber::setNBuffers ( unsigned  nbuffers)
inline

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.

Parameters
nbuffers: Number of ring buffers.
Examples:
manGrabV4l2.cpp.

Definition at line 277 of file vpV4l2Grabber.h.

Referenced by vpV4l2Grabber().

◆ setPixelFormat()

void vpV4l2Grabber::setPixelFormat ( vpV4l2PixelFormatType  pixelformat)
inline

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

Parameters
pixelformat: Camera pixel format coding.
Examples:
grabV4l2.cpp.

Definition at line 294 of file vpV4l2Grabber.h.

Referenced by open(), and vpV4l2Grabber().

◆ setScale()

◆ setVerboseMode()

void vpV4l2Grabber::setVerboseMode ( bool  verbose)
inline

Activates the verbose mode to print additional information on stdout.

Parameters
verbose: If true activates the verbose mode.
Examples:
grabV4l2.cpp.

Definition at line 248 of file vpV4l2Grabber.h.

References DEFAULT_INPUT.

◆ setWidth()

void vpV4l2Grabber::setWidth ( unsigned  w)
inline

Set image width to acquire.

Examples:
manGrabV4l2.cpp.

Definition at line 257 of file vpV4l2Grabber.h.

Referenced by setScale().

Member Data Documentation

◆ DEFAULT_INPUT

const unsigned int vpV4l2Grabber::DEFAULT_INPUT = 2
static

Definition at line 137 of file vpV4l2Grabber.h.

Referenced by setVerboseMode(), and vpV4l2Grabber().

◆ DEFAULT_SCALE

const unsigned int vpV4l2Grabber::DEFAULT_SCALE = 2
static

Definition at line 138 of file vpV4l2Grabber.h.

Referenced by setHeight(), and vpV4l2Grabber().

◆ FRAME_SIZE

const unsigned int vpV4l2Grabber::FRAME_SIZE = 288
static

Definition at line 144 of file vpV4l2Grabber.h.

Referenced by close().

◆ height

◆ init

◆ MAX_BUFFERS

const unsigned int vpV4l2Grabber::MAX_BUFFERS = 32
static

Definition at line 143 of file vpV4l2Grabber.h.

Referenced by close().

◆ MAX_CTRL

const unsigned int vpV4l2Grabber::MAX_CTRL = 32
static

Definition at line 142 of file vpV4l2Grabber.h.

Referenced by close().

◆ MAX_FORMAT

const __u32 vpV4l2Grabber::MAX_FORMAT = 32
static

Definition at line 141 of file vpV4l2Grabber.h.

Referenced by close().

◆ MAX_INPUTS

const __u32 vpV4l2Grabber::MAX_INPUTS = 16
static

Definition at line 139 of file vpV4l2Grabber.h.

Referenced by close().

◆ MAX_NORM

const __u32 vpV4l2Grabber::MAX_NORM = 16
static

Definition at line 140 of file vpV4l2Grabber.h.

Referenced by close().

◆ width