JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
jevois::VideoMapping Struct Reference

#include <jevois/Core/VideoMapping.H>

Simple struct to hold video mapping definitions for the processing Engine.

This struct specifies an output video format, resolution, and frame rate (to be send to the end user over USB), the corresponding camera capture video format, resolution and frame rate, and the Module to use to process the camera frames and generate the corresponding output frames. This class also provides conversion functions between frame rate and frame interval periods for both USB and V4L2, which use different units.

Operation of JeVois is based on a list of available VideoMapping definitions, which is configured in a file called JEVOIS:config/videomappings.cfg on the microSD card. The video mappings indicate which output formats are exposed to the host computer connected over USB, and which corresponding camera format and vision processing module should be used when a given output format is selected by video capture software running on the host computer.

See User guide to video modes and mappings for explanations about how to organize videomappings.cfg

Definition at line 41 of file VideoMapping.H.

Collaboration diagram for jevois::VideoMapping:

Public Member Functions

std::string sopath () const
 Return the full absolute path and file name of the module's .so file. More...
 
unsigned int osize () const
 Return the size in bytes of an output image. More...
 
unsigned int csize () const
 Return the size in bytes of a camera image. More...
 
bool match (unsigned int oformat, unsigned int owidth, unsigned int oheight, float oframespersec) const
 Return true if this VideoMapping's output format is a match to the given output parameters. More...
 
std::string ostr () const
 Convenience function to print out FCC WxH @ fps, for the output (UVC) format. More...
 
std::string cstr () const
 Convenience function to print out FCC WxH @ fps, for the input (camera) format. More...
 
std::string str () const
 Convenience function to print out the whole mapping in a human-friendly way. More...
 

Static Public Member Functions

static float uvcToFps (unsigned int interval)
 Convert from USB/UVC interval to fps. More...
 
static unsigned int fpsToUvc (float fps)
 Convert from fps to USB/UVC interval. More...
 
static float v4l2ToFps (struct v4l2_fract const &interval)
 Convert from V4L2 interval to fps. More...
 
static struct v4l2_fract fpsToV4l2 (float fps)
 Convert from fps to V4L2 interval. More...
 

Public Attributes

unsigned int ofmt
 output pixel format, or 0 for no output over USB More...
 
unsigned int ow
 output width More...
 
unsigned int oh
 output height More...
 
float ofps
 output frame rate in frames/sec More...
 
unsigned int cfmt
 camera pixel format More...
 
unsigned int cw
 camera width More...
 
unsigned int ch
 camera height More...
 
float cfps
 camera frame rate in frames/sec More...
 
unsigned int uvcformat
 USB-UVC format number (1-based) More...
 
unsigned int uvcframe
 USB UVC frame number (1-based) More...
 
std::string vendor
 Module creator name, used as a directory to organize the modules. More...
 
std::string modulename
 Name of the Module that will process this mapping. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out, VideoMapping const &m)
 Stream a VideoMapping out, intended for machines. More...
 
std::istream & operator>> (std::istream &in, VideoMapping &m)
 Stream a VideoMapping in, intended for machines. More...
 
std::vector< VideoMappingloadVideoMappings (size_t &defidx)
 Load all the video mappings from the default config file. More...
 
std::vector< VideoMappingvideoMappingsFromStream (std::istream &is, size_t &defidx)
 Parse all the mappings in a config file and also indicate which one is the default. More...
 

Member Function Documentation

unsigned int jevois::VideoMapping::csize ( ) const

Return the size in bytes of a camera image.

Definition at line 55 of file VideoMapping.C.

References jevois::v4l2ImageSize().

std::string jevois::VideoMapping::cstr ( ) const

Convenience function to print out FCC WxH @ fps, for the input (camera) format.

Definition at line 93 of file VideoMapping.C.

References jevois::fccstr().

unsigned int jevois::VideoMapping::fpsToUvc ( float  fps)
static

Convert from fps to USB/UVC interval.

Definition at line 66 of file VideoMapping.C.

Referenced by main().

struct v4l2_fract jevois::VideoMapping::fpsToV4l2 ( float  fps)
static

Convert from fps to V4L2 interval.

Definition at line 79 of file VideoMapping.C.

Referenced by jevois::Gadget::setFormat(), and jevois::Camera::setFormat().

bool jevois::VideoMapping::match ( unsigned int  oformat,
unsigned int  owidth,
unsigned int  oheight,
float  oframespersec 
) const

Return true if this VideoMapping's output format is a match to the given output parameters.

Definition at line 293 of file VideoMapping.C.

Referenced by jevois::Engine::findVideoMapping().

unsigned int jevois::VideoMapping::osize ( ) const

Return the size in bytes of an output image.

Definition at line 51 of file VideoMapping.C.

References jevois::v4l2ImageSize().

Referenced by jevois::VideoOutputNone::setFormat(), jevois::VideoDisplay::setFormat(), and jevois::Gadget::setFormat().

std::string jevois::VideoMapping::ostr ( ) const

Convenience function to print out FCC WxH @ fps, for the output (UVC) format.

Definition at line 85 of file VideoMapping.C.

References jevois::fccstr().

std::string jevois::VideoMapping::sopath ( ) const

Return the full absolute path and file name of the module's .so file.

Definition at line 45 of file VideoMapping.C.

References modulename, and vendor.

std::string jevois::VideoMapping::str ( ) const

Convenience function to print out the whole mapping in a human-friendly way.

Definition at line 101 of file VideoMapping.C.

float jevois::VideoMapping::uvcToFps ( unsigned int  interval)
static

Convert from USB/UVC interval to fps.

This function rounds to the nearest 1/100 fps.

Definition at line 59 of file VideoMapping.C.

Referenced by jevois::Engine::getVideoMappingIdx().

float jevois::VideoMapping::v4l2ToFps ( struct v4l2_fract const &  interval)
static

Convert from V4L2 interval to fps.

This function rounds to the nearest 1/100 fps.

Definition at line 72 of file VideoMapping.C.

Friends And Related Function Documentation

std::vector< VideoMapping > loadVideoMappings ( size_t &  defidx)
related

Load all the video mappings from the default config file.

std::ostream & operator<< ( std::ostream &  out,
VideoMapping const &  m 
)
related

Stream a VideoMapping out, intended for machines.

Note that no std::endl is issued at the end.

std::istream & operator>> ( std::istream &  in,
VideoMapping m 
)
related

Stream a VideoMapping in, intended for machines.

Note that the assumption is that the mapping is clean (no extra garbage).

std::vector< VideoMapping > videoMappingsFromStream ( std::istream &  is,
size_t &  defidx 
)
related

Parse all the mappings in a config file and also indicate which one is the default.

The contents of the file are sorted so that the resulting vector is ordered by increasing 1) format fcc, then 2) resolution (from large to small, looking at x first), and 3) framerate (from high to low).

In case of duplicate output formats, frame rates will be decreased by 1fps for each additional duplicate. This is because we need to present the host computer with distinct video formats so that users can select the one they want. For example:

YUYV 320 240 60.0 YUYV 320 240 60.0 JeVois SaveVideo
YUYV 320 240 60.0 YUYV 320 240 60.0 VendorX MyModule
YUYV 320 240 60.0 YUYV 320 240 60.0 VendorY MyModule
YUYV 320 240 60.0 YUYV 320 240 60.0 VendorZ MyModule

will be disambiguated into:

YUYV 320 240 60.0 YUYV 320 240 60.0 JeVois SaveVideo
YUYV 320 240 59.0 YUYV 320 240 60.0 VendorX MyModule
YUYV 320 240 58.0 YUYV 320 240 60.0 VendorY MyModule
YUYV 320 240 57.0 YUYV 320 240 60.0 VendorZ MyModule

and in guvcview or similar program running on a host computer, these 4 mappings will be available since they correspond to 4 different framerates. It is recommended that you issue a listmapping command in the JeVois command-line interface to confirm the final mappings that are used at runtime after any adjustments; see Command-line interface user guide for details.

defidx is the index of the default format in the resulting vector of mappings. If several default formats are specified, the first one prevails.

See User guide to video modes and mappings for explanations about how to organize videomappings.cfg

Member Data Documentation

unsigned int jevois::VideoMapping::cfmt

camera pixel format

Definition at line 48 of file VideoMapping.H.

Referenced by main(), and jevois::Camera::setFormat().

float jevois::VideoMapping::cfps

camera frame rate in frames/sec

Definition at line 51 of file VideoMapping.H.

Referenced by main(), and jevois::Camera::setFormat().

unsigned int jevois::VideoMapping::ch

camera height

Definition at line 50 of file VideoMapping.H.

Referenced by main(), and jevois::Camera::setFormat().

unsigned int jevois::VideoMapping::cw

camera width

Definition at line 49 of file VideoMapping.H.

Referenced by main(), and jevois::Camera::setFormat().

std::string jevois::VideoMapping::modulename

Name of the Module that will process this mapping.

Definition at line 58 of file VideoMapping.H.

Referenced by sopath().

unsigned int jevois::VideoMapping::ofmt

output pixel format, or 0 for no output over USB

Definition at line 43 of file VideoMapping.H.

Referenced by jevois::VideoOutputNone::setFormat(), jevois::VideoDisplay::setFormat(), and jevois::Gadget::setFormat().

float jevois::VideoMapping::ofps

output frame rate in frames/sec

Definition at line 46 of file VideoMapping.H.

Referenced by jevois::Engine::getVideoMappingIdx(), and jevois::Gadget::setFormat().

unsigned int jevois::VideoMapping::oh
unsigned int jevois::VideoMapping::ow
unsigned int jevois::VideoMapping::uvcformat

USB-UVC format number (1-based)

Definition at line 53 of file VideoMapping.H.

Referenced by jevois::Engine::getVideoMappingIdx().

unsigned int jevois::VideoMapping::uvcframe

USB UVC frame number (1-based)

Definition at line 54 of file VideoMapping.H.

Referenced by jevois::Engine::getVideoMappingIdx().

std::string jevois::VideoMapping::vendor

Module creator name, used as a directory to organize the modules.

Definition at line 56 of file VideoMapping.H.

Referenced by sopath().


The documentation for this struct was generated from the following files: