class Video

The Video class is an abstract base class for video device interfacing

Inheritance:


Public Methods

virtual int bytesperpixel()
Returns bytes per pixel supplied by device
virtual void circle(float x, float y, int r, Color color = default_color)
Default draws a crosshair with input center and radius
virtual void clearcircle(float x, float y, int r)
Default calls circle with transparent color
virtual void clearcubic(float x, float y, int length, float angle, float a, float b, float c)
Default does nothing
virtual void clearline(float x, float y, int length, float angle, int samp = 1)
Erases a line by drawing a transparent line
virtual void clearline2(float x1, float y1, float x2, float y2)
Default calls line2 with transparent color
virtual void close()
Clean up function for Video class
virtual void cubic(float x, float y, int length, float angle, float a, float b, float c, Color color = default_color)
Default draws nothing
virtual void* current_frame_ptr()
This is the function which gives the pointer to the current base of memory
virtual char* device_info()
Sometimes, it's nice to be able to dump a description of the device
virtual void* direct_memptr()
Returns the pointer to framebuffer memory if device is memory mappable, otherwise returns NULL
virtual int grab(Image &image, int x, int y, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
virtual int grab(int *image, int x, int y, int width, int height, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
General purpose grab functions, allowing grabbing of windows at any orientation and any subsampling rate
virtual int grab_aligned(Image &image, int x, int y, int sampw =1, int samph =1, short int mask = 0xff)
virtual int grab_aligned(int *image, float &x, float &y, int width, int height, int sampw =1, int samph =1, short int mask = 0xff)
Acquire a rectangle of the image oriented with the coordinate axes
virtual int grab_aligned(Image &image, float &x, float &y, int sampw =1, int samph =1, short int mask = 0xff)
virtual int grab_region(int *image, int lx, int ly, int ux, int uy, int sampw =1, int samph = 1)
Grab a region using upper-left/lower-right parameters
virtual int grab_region(Image &image, int lx, int ly, int sampw =1, int samph = 1)
virtual int grab_static(int *image, int x, int y, int width, int height, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
These functions are for devices such as VCR's or image sequences where, particularly during initialization, it makes sense not to forward the sequence
virtual int grab_static(Image &image, int x, int y, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
int height()
Return image height
int in_view(int cx, int cy, int w, int h, float angle)
int in_view(int cx, int cy, int w, int h)
Checks if a window is completely within the boundaries of the full image
int in_view(const Image &x, int cx, int cy)
int in_view(const Image &x, int cx, int cy, float angle)
int in_view2(int x1, int y1, int x2, int y2)
virtual int is_mappable()
Returns the value of _is_mappable, which should be TRUE for devices that have memory mapping capability
virtual void line(float x, float y, int length, float angle, Color color = default_color, int samp = 1)
Video::line is a pure virtual function
virtual void line2(float x1, float y1, float x2, float y2, Color color = default_color)
Same as line, but inputs are endpoint coordinates
Device_output_type output_data_type()
For determining the current output data type
virtual int post_grab()
Same as pre_grab, but for processing afterwards
virtual int pre_grab()
This functions are here to handle any special-purpose buffer management or whatever needed before acquiring images
virtual void set_grab_type(Device_output_type ot)
Allow switching of type of data delivered by the device
virtual int show(int x, int y, int width, int height, int *image)
This is a pure virtual function
virtual int show(Image &im, int x=100, int y=100)
Video(int nbytes, int nc_in = 640, int nr_in = 480)
Basic bookeeping and info transfer
int width()
Return image width
~Video()
Default is simply a call to Video::close()

Protected Fields

int _bytesperpixel
int _is_mappable
int fg_ncols
int fg_nrows
Device_output_type input_type
int ncols
int nrows
Device_output_type output_type

Protected Methods

int adjust_to_first_coord(float &x, int width)
Used to compute the location of the first pixel in an aligned grab
virtual int map_color(Color colin)
This is a pure virtual function
void map_image(int *x, int npixels)
Change the data presentation as requested
void map_image(Image &x)
void set_fg_size(int nrows_in, int ncols_in)
Set the size of the framegrabber, which may not be the same as the size of the camera image
Device_output_type set_input_type(Device_output_type ot)
Allows setting the input type
void set_size(int nrows_in, int ncols_in)
In some cases, you can't tell the size until you open the device This allows you to set the size later in the constructor

Documentation

The Video class is an abstract base class for video device interfacing. It provides an interface between tracking software and video hardware.

Video-derived classes fulfill the following broad functions: Initialization and closing of hardware devices. Transfers (grabbing) of data from hardware device into memory, or, if the device can be memory mapped, access to pixel data. Displays of lines, etc., on the device monitor (in some instances, the user terminal may function as the device monitor).

For purposes of porting XVision to a new hardware device, a class that instantiates these functions must be defined. In many cases, the default Video class methods will be sufficient, although code at this level should be optimized for the specific device for best performance. The easiest way to create a new class is to model it on one of the many classes in the Devices directory. Most non-virtual member functions will probably not need to be rewritten in derived classes.

The classes MonoVideo and ColorVideo are derived from the Video class, and most instantiations should be derived from one of these (see comments for MonoVideo and ColorVideo classes).

Video class objects have an output type associated with them, which are one of the Device_output_type's enumerated in Video.hh. This allows one to switch (even during execution) between returning RGB data or monochrome intensity data, for example.

Many video devices are memory mapped in some fashion. If so, it's sometimes advantageous to bypass the usual memory acquisition routines and perform inline processing or dump memory straight to the display device without copying.

Video classes grab windows, which are rectangular, and have the following parameters: position (x,y) in pixels, orientation in radians, and subsampling rates (sampw,samph) in pixels. The conventions are that the position coordinates indicate the center of the window, and that the 0 orientation has window sides aligned with the camera image. Orientation is also measured to coincide with image coordinates (i.e., (0,0) at the top left and increasing Y values going down). Thus, a window that is tilted counterclockwise on the monitor (or in the image), would have NEGATIVE angular orientation. This is the same convention that is used in the rest of the XVision system.

int _bytesperpixel

int _is_mappable

int ncols

int nrows

int fg_ncols

int fg_nrows

virtual int map_color(Color colin)
This is a pure virtual function. Instantiate this to deal with mapping default colors listed in Tracker.hh as appropriate for the monitor display.

void set_size(int nrows_in, int ncols_in)
In some cases, you can't tell the size until you open the device This allows you to set the size later in the constructor

void set_fg_size(int nrows_in, int ncols_in)
Set the size of the framegrabber, which may not be the same as the size of the camera image

Device_output_type output_type

Device_output_type input_type

Device_output_type set_input_type(Device_output_type ot)
Allows setting the input type. By default, this is monochrome for a monochrome device, but in some cases (e.g. the IndyCam), you have to convert from color to monochrome in software, so you need to actually set this input type.

void map_image(int *x, int npixels)
Change the data presentation as requested. Unfortunately, for upwards compatibility we need two versions.

void map_image(Image &x)

int adjust_to_first_coord(float &x, int width)
Used to compute the location of the first pixel in an aligned grab

Video(int nbytes, int nc_in = 640, int nr_in = 480)
Basic bookeeping and info transfer. The only required argument is the number of bytes per pixel in this device (usually 1). The other arguments indicate image size: width and height in pixels.

The constructor should either initialize the video device or call a function which does the initialization. Initialization should include hardware initialization, hardware parameter settings, memory mapping (if available), and so on. Example constructors in specific Device classes in the Devices directory may help, but generally, this function will be unique to the hardware and its drivers.

~Video()
Default is simply a call to Video::close(). If any memory was allocated in the constructor, it should also be deleted here.

virtual char* device_info()
Sometimes, it's nice to be able to dump a description of the device. Define this function with a descriptive string when instantiating.

virtual void set_grab_type(Device_output_type ot)
Allow switching of type of data delivered by the device. By default, calling this generates an error, hence for a monochrome device, trying to set the data type will cause an error.

Device_output_type output_data_type()
For determining the current output data type

virtual int pre_grab()
This functions are here to handle any special-purpose buffer management or whatever needed before acquiring images. The return value can be used to, for example, determine whether a DMA buffer was successfully attached.

virtual int post_grab()
Same as pre_grab, but for processing afterwards

virtual void close()
Clean up function for Video class. By default it does nothing.

int width()
Return image width.

int height()
Return image height.

virtual void* current_frame_ptr()
This is the function which gives the pointer to the current base of memory. Up to the instantiator to fill it in.

virtual int is_mappable()
Returns the value of _is_mappable, which should be TRUE for devices that have memory mapping capability

virtual void* direct_memptr()
Returns the pointer to framebuffer memory if device is memory mappable, otherwise returns NULL

virtual int bytesperpixel()
Returns bytes per pixel supplied by device

int in_view(int cx, int cy, int w, int h)
Checks if a window is completely within the boundaries of the full image. This function is overloaded to allow several argument formats: (centerx, centery, width, height), (centerx, centery, width, height, orientation), (Image class object, centerx, centery), (Image class object, centerx, centery, orientation), in_view2 takes (leftx, topy, rightx, bottomy).

int in_view(int cx, int cy, int w, int h, float angle)

int in_view(const Image &x, int cx, int cy)

int in_view(const Image &x, int cx, int cy, float angle)

int in_view2(int x1, int y1, int x2, int y2)

virtual int grab(int *image, int x, int y, int width, int height, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
General purpose grab functions, allowing grabbing of windows at any orientation and any subsampling rate. Acquires a rectangle of data at an angle, and inserts it in row-major format into an array or an Image class object. Defaults are 8 bit mode oriented with coordinate axis. This version does a pixel-to-pixel mapping between framegrabber and buffer, even if this causes the area covered by the window to grow and shrink, depending on the orientation. x and y are the center of the window.

virtual int grab(Image &image, int x, int y, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)

virtual int grab_aligned(int *image, float &x, float &y, int width, int height, int sampw =1, int samph =1, short int mask = 0xff)
Acquire a rectangle of the image oriented with the coordinate axes. By default, this just calls grab, but in many cases its possible to optimize acquisition for this case, so we have it here. Also, note the use of floats for the center. This makes it possible to have even-sized windows and still get what you'd expect. The actual coordinates that are acquired are returned in the arguments.

virtual int grab_aligned(Image &image, float &x, float &y, int sampw =1, int samph =1, short int mask = 0xff)

virtual int grab_aligned(Image &image, int x, int y, int sampw =1, int samph =1, short int mask = 0xff)

virtual int grab_static(int *image, int x, int y, int width, int height, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)
These functions are for devices such as VCR's or image sequences where, particularly during initialization, it makes sense not to forward the sequence. By default, they act the same as the normal grab functions.

virtual int grab_static(Image &image, int x, int y, float angle = 0.0, int sampw =1, int samph =1, short int mask = 0xff)

virtual int grab_region(int *image, int lx, int ly, int ux, int uy, int sampw =1, int samph = 1)
Grab a region using upper-left/lower-right parameters

virtual int grab_region(Image &image, int lx, int ly, int sampw =1, int samph = 1)

virtual int show(int x, int y, int width, int height, int *image)
This is a pure virtual function. Derived class methods should show an image on the video screen at the specified location with the specified height and width.

virtual int show(Image &im, int x=100, int y=100)

virtual void line(float x, float y, int length, float angle, Color color = default_color, int samp = 1)
Video::line is a pure virtual function. Derived class methods should draw a line on the monitor with specified center (x,y), length, and angle.

virtual void clearline(float x, float y, int length, float angle, int samp = 1)
Erases a line by drawing a transparent line. For some monitor devices, (particularly those without an overlay plane) it may not be necessary to actively erase anything, since the screen may refresh often, effectively erasing drawn lines.

virtual void line2(float x1, float y1, float x2, float y2, Color color = default_color)
Same as line, but inputs are endpoint coordinates. Default does a conversion and call to line.

virtual void clearline2(float x1, float y1, float x2, float y2)
Default calls line2 with transparent color

virtual void circle(float x, float y, int r, Color color = default_color)
Default draws a crosshair with input center and radius

virtual void clearcircle(float x, float y, int r)
Default calls circle with transparent color

virtual void cubic(float x, float y, int length, float angle, float a, float b, float c, Color color = default_color)
Default draws nothing. Implemented version should draw a cubic curve segment with starting point (x,y), at orientation "angle", length "length," and coefficents a, b, and c, where: y = a x^3 + b x^2 + c x + d. d is implicit in the fact that the starting point is y. The angular orientation should indicate the orientation of the x-axis.

virtual void clearcubic(float x, float y, int length, float angle, float a, float b, float c)
Default does nothing


Direct child classes:
MonoVideo
IT_FG101
IT_FG101
IT_FG101
Galileo
ColorVideo
way

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de