V4l2Grabber¶
- class V4l2Grabber(*args, **kwargs)¶
Bases:
FrameGrabber
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/vpConfig.h> #include <visp3/core/vpImage.h> #include <visp3/gui/vpDisplayOpenCV.h> #include <visp3/gui/vpDisplayX.h> #include <visp3/io/vpImageStorageWorker.h> #include <visp3/sensor/vpV4l2Grabber.h> #define USE_COLOR // Comment to acquire gray level images void usage(const char *argv[], int error) { std::cout << "SYNOPSIS" << std::endl << " " << argv[0] << " [--device <index>]" << " [--scale <subsampling factor>]" << " [--seqname <sequence name>]" << " [--record <mode>]" << " [--no-display]" << " [--help] [-h]" << std::endl << std::endl; std::cout << "DESCRIPTION" << std::endl << " --device <index> " << std::endl << " Camera device index. Set 0 to dial with the first camera," << std::endl << " and 1 to dial with the second camera attached to the computer." << std::endl << " Default: 0 to consider /dev/video0 device." << std::endl << std::endl << " --scale <subsampling factor>" << std::endl << " Subsampling factor applied to the images captured by the device." << std::endl << " Default: 1" << std::endl << std::endl << " --seqname <sequence name>" << std::endl << " Name of the sequence of image to create (ie: /tmp/image%04d.jpg)." << std::endl << " Default: empty." << std::endl << std::endl << " --record <mode>" << std::endl << " Allowed values for mode are:" << std::endl << " 0: record all the captures images (continuous mode)," << std::endl << " 1: record only images selected by a user click (single shot mode)." << std::endl << " Default mode: 0" << std::endl << std::endl << " --no-display" << std::endl << " Disable displaying captured images." << std::endl << " When used and sequence name specified, record mode is internally set to 1 (continuous mode)." << std::endl << std::endl << " --help, -h" << std::endl << " Print this helper message." << std::endl << std::endl; std::cout << "USAGE" << std::endl << " Example to visualize images:" << std::endl << " " << argv[0] << std::endl << std::endl << " Example to visualize images from a second camera:" << std::endl << " " << argv[0] << " --device 1" << std::endl << std::endl << " Examples to record a sequence:" << std::endl << " " << argv[0] << " --seqname I%04d.png" << std::endl << " " << argv[0] << " --seqname folder/I%04d.png --record 0" << std::endl << std::endl << " Examples to record single shot images:\n" << " " << argv[0] << " --seqname I%04d.png --record 1\n" << " " << argv[0] << " --seqname folder/I%04d.png --record 1" << std::endl << std::endl; if (error) { std::cout << "Error" << std::endl << " " << "Unsupported parameter " << argv[error] << std::endl; } } int main(int argc, const char *argv[]) { #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_THREADS) #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME ; #endif 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; bool opt_display = true; for (int i = 1; i < argc; i++) { if (std::string(argv[i]) == "--device") { opt_device = std::atoi(argv[i + 1]); i++; } else if (std::string(argv[i]) == "--scale") { opt_scale = (unsigned int)atoi(argv[i + 1]); i++; } else if (std::string(argv[i]) == "--seqname") { opt_seqname = std::string(argv[i + 1]); i++; } else if (std::string(argv[i]) == "--record") { opt_record_mode = std::atoi(argv[i + 1]); i++; } else if (std::string(argv[i]) == "--no-display") { opt_display = false; } else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") { usage(argv, 0); return EXIT_SUCCESS; } else { usage(argv, i); return EXIT_FAILURE; } } if ((!opt_display) && (!opt_seqname.empty())) { opt_record_mode = 0; } std::cout << "Use device : " << opt_device << std::endl; std::cout << "Recording : " << (opt_seqname.empty() ? "disabled" : "enabled") << std::endl; std::cout << "Display : " << (opt_display ? "enabled" : "disabled") << 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 vpV4l2Grabber g; 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; vpDisplay *d = nullptr; if (opt_display) { #if !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV)) std::cout << "No image viewer is available..." << std::endl; opt_display = false; #endif } if (opt_display) { #ifdef VISP_HAVE_X11 d = new vpDisplayX(I); #elif defined(HAVE_OPENCV_HIGHGUI) d = new vpDisplayOpenCV (I); #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); vpDisplay::display (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 ); vpDisplay::flush (I); } image_queue.cancel(); image_storage_thread.join(); if (d) { delete d; } } 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 tutorial 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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif 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 }
Note
See vpFrameGrabber
Overloaded function.
__init__(self: visp._visp.sensor.V4l2Grabber) -> None
Default constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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; 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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_X11) vpDisplayX *d; vpImage<vpRGBa> I; vpRect roi(0, 0, 320, 240); // specify the region to crop vpV4l2Grabber g; bool first = true; while (1) { g.acquire(I, roi); if(first) { d = new vpDisplayX(I); first = false; } vpDisplay::display(I); vpDisplay::flush(I); if (vpDisplay::getClick(I, false)) break; } vpImageIo::write(I, "image.pgm"); // Save the last image delete d; #endif
__init__(self: visp._visp.sensor.V4l2Grabber, verbose: bool) -> None
__init__(self: visp._visp.sensor.V4l2Grabber, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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.
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
- Parameters:
- input
Video input port.
- scale
Decimation factor.
__init__(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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 enough 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
- Parameters:
- I
Image data structure (grey 8 bits image)
- input
Video input port.
- scale
Decimation factor.
__init__(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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.
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
- Parameters:
- I
Image data structure (Color RGB32 bits image)
- input
Video input port.
- scale
Decimation factor.
Methods
Overloaded function.
Overloaded function.
Close the video device.
Return the field (odd or even) corresponding to the last acquired frame.
Return the framerate of the acquisition.
Get the pixel format used for capture.
Overloaded function.
Set the device name.
Set the frame format depending on the framerate acquisition.
Set image height to acquire.
Set the video input port on the board.
Set the number of buffers required for streaming data.
Set the pixel format for capture.`If the specified pixel format is out of range, we set the V4L2_RGB24_FORMAT.
Set the decimation factor applied to full resolution images (768x576).
Activates the verbose mode to print additional information on stdout.
Set image width to acquire.
Inherited Methods
init
Return the number of rows in the image.
Return the number of columns in the image.
Operators
__doc__
Overloaded function.
__module__
Attributes
DEFAULT_INPUT
DEFAULT_SCALE
FRAME_SIZE
MAX_BUFFERS
MAX_CTRL
MAX_FORMAT
MAX_INPUTS
MAX_NORM
V4L2_BGR24_FORMAT
V4L2_FRAME_FORMAT
V4L2_GREY_FORMAT
V4L2_IMAGE_FORMAT
V4L2_MAX_FORMAT
V4L2_RGB24_FORMAT
V4L2_RGB32_FORMAT
V4L2_YUYV_FORMAT
__annotations__
framerate_25fps
framerate_50fps
init
- class V4l2FrameFormatType(self, value: int)¶
Bases:
pybind11_object
Pixel format type for capture.
Values:
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
- class V4l2FramerateType(self, value: int)¶
Bases:
pybind11_object
Pixel format type for capture.
Values:
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
- class V4l2PixelFormatType(self, value: int)¶
Bases:
pybind11_object
Pixel format type for capture.
Values:
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
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.sensor.V4l2Grabber) -> None
Default constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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; 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> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_X11) vpDisplayX *d; vpImage<vpRGBa> I; vpRect roi(0, 0, 320, 240); // specify the region to crop vpV4l2Grabber g; bool first = true; while (1) { g.acquire(I, roi); if(first) { d = new vpDisplayX(I); first = false; } vpDisplay::display(I); vpDisplay::flush(I); if (vpDisplay::getClick(I, false)) break; } vpImageIo::write(I, "image.pgm"); // Save the last image delete d; #endif
__init__(self: visp._visp.sensor.V4l2Grabber, verbose: bool) -> None
__init__(self: visp._visp.sensor.V4l2Grabber, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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.
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
- Parameters:
- input
Video input port.
- scale
Decimation factor.
__init__(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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 enough 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
- Parameters:
- I
Image data structure (grey 8 bits image)
- input
Video input port.
- scale
Decimation factor.
__init__(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa, input: int, scale: int = vpV4l2Grabber::DEFAULT_SCALE) -> None
Constructor.
Setup the Video For Linux Two (V4L2) driver in streaming 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.
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
- Parameters:
- I
Image data structure (Color RGB32 bits image)
- input
Video input port.
- scale
Decimation factor.
- acquire(*args, **kwargs)¶
Overloaded function.
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray) -> None
Acquire a grey level image.
Note
See getField()
- Parameters:
- I
Image data structure (8 bits image)
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray, roi: visp._visp.core.Rect) -> None
Acquire a grey level image.
Note
See getField()
- Parameters:
- I
Image data structure (8 bits image)
- roi
Region of interest to grab from the full resolution image.
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray, timestamp: timeval, roi: visp._visp.core.Rect = vpRect()) -> None
Acquire a grey level image.
Note
See getField()
- 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.
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa) -> None
Acquire a color image.
Note
See getField()
- Parameters:
- I
Image data structure (32 bits image)
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa, roi: visp._visp.core.Rect) -> None
Acquire a color image.
Note
See getField()
- Parameters:
- I
Image data structure (32 bits image)
- roi
Region of interest to grab from the full resolution image.
acquire(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa, timestamp: timeval, roi: visp._visp.core.Rect = vpRect()) -> None
Acquire a color image.
Note
See getField()
- 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.
- getField(self) bool ¶
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.
Note
See acquire() , setFramerate()
- Returns:
Field of the acquired frame (0 if odd field, 1 if even field).
- getFramerate(self) visp._visp.sensor.V4l2Grabber.V4l2FramerateType ¶
Return the framerate of the acquisition.
Note
See setFramerate()
- Returns:
The actual framerate of the framegrabber.
- getPixelFormat(self) visp._visp.sensor.V4l2Grabber.V4l2PixelFormatType ¶
Get the pixel format used for capture.
- Returns:
Camera pixel format coding.
- open(*args, **kwargs)¶
Overloaded function.
open(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageGray) -> None
Initialize image acquisition in grey format. Set the pixel format acquisition to vpV4l2Grabber::V4L2_GREY_FORMAT .
- Parameters:
- I
Image data structure (8 bits image). Once the device is open, the image is resized to the current acquisition size.
open(self: visp._visp.sensor.V4l2Grabber, I: visp._visp.core.ImageRGBa) -> None
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.
- setFramerate(self, framerate: visp._visp.sensor.V4l2Grabber.V4l2FramerateType) None ¶
Set the frame format depending on the framerate 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() ).
Note
See getFramerate() , setNBuffers()
- Parameters:
- framerate: visp._visp.sensor.V4l2Grabber.V4l2FramerateType¶
The framerate for the acquisition.
If vpV4l2Grabber::framerate_25fps use vpV4l2Grabber::V4L2_IMAGE_FORMAT ,
else if vpV4l2Grabber::framerate_50fps use vpV4l2Grabber::V4L2_FRAME_FORMAT .
- setInput(self: visp._visp.sensor.V4l2Grabber, input: int = vpV4l2Grabber::DEFAULT_INPUT) None ¶
Set the video input port on the board.
- setNBuffers(self, nbuffers: int) None ¶
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.
- setPixelFormat(self, pixelformat: visp._visp.sensor.V4l2Grabber.V4l2PixelFormatType) None ¶
Set the pixel format for capture.`If the specified pixel format is out of range, we set the V4L2_RGB24_FORMAT.
- Parameters:
- pixelformat: visp._visp.sensor.V4l2Grabber.V4l2PixelFormatType¶
Camera pixel format coding.
- setScale(self: visp._visp.sensor.V4l2Grabber, scale: int = vpV4l2Grabber::DEFAULT_SCALE) None ¶
Set the decimation factor applied to full resolution images (768x576).
An other way to specify the image size is to use setWidth() and setHeight() .
- Parameters:
- scale
Decimation factor. If scale is set to 2, 384x288 images will be acquired.