JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#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 61 of file VideoMapping.H.
Public Member Functions | |
std::string | path () const |
Return the full absolute path the module's directory. | |
std::string | sopath (bool delete_old_versions=false) const |
Return the full absolute path and file name of the module's .so or .py file. | |
std::string | srcpath () const |
Return the full absolute path and file name of the module's .C or .py file. | |
std::string | cmakepath () const |
Return the full absolute path and file name of the module's CMakeLists.txt file. | |
std::string | modinfopath () const |
Return the full absolute path and file name of the module's modinfo.html file. | |
unsigned int | osize () const |
Return the size in bytes of an output image. | |
unsigned int | csize () const |
Return the size in bytes of a camera image. | |
unsigned int | c2size () const |
Return the size in bytes of a scaled camera image, if stream==RawAndScaled, otherwise 0. | |
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. | |
std::string | ostr () const |
Convenience function to print out FCC WxH @ fps, for the output (UVC) format. | |
std::string | cstr () const |
Convenience function to print out FCC WxH @ fps, for the input (camera) format. | |
std::string | c2str () const |
Convenience function to print out FCC WxH @ fps, for the scaled camera input format, if stream==RawAndScaled. | |
std::string | cstrall () const |
Convenience function to print out FCC WxH @ fps plus possibly second stream, for the input (camera) format. | |
std::string | str () const |
Convenience function to print out the whole mapping in a human-friendly way. | |
std::string | menustr () const |
Convenience function to print out the whole mapping in a human-friendly way to be used in a menu. | |
std::string | menustr2 () const |
Convenience function to print out the whole mapping in a human-friendly way to be used in a menu. | |
bool | hasSameSpecsAs (VideoMapping const &other) const |
Equality operator for specs but not vendor or module name. | |
bool | isSameAs (VideoMapping const &other) const |
Equality operator for specs and also vendor or module name. | |
void | setModuleType () |
Determine whether module is C++ or python and set ispython flag accordingly. | |
Static Public Member Functions | |
static float | uvcToFps (unsigned int interval) |
Convert from USB/UVC interval to fps. | |
static unsigned int | fpsToUvc (float fps) |
Convert from fps to USB/UVC interval. | |
static float | v4l2ToFps (struct v4l2_fract const &interval) |
Convert from V4L2 interval to fps. | |
static struct v4l2_fract | fpsToV4l2 (float fps) |
Convert from fps to V4L2 interval. | |
Public Attributes | |
unsigned int | ofmt = 0 |
output pixel format, or 0 for no output over USB | |
unsigned int | ow = 0 |
output width | |
unsigned int | oh = 0 |
output height | |
float | ofps = 0.0F |
output frame rate in frames/sec | |
unsigned int | cfmt = 0 |
camera pixel format | |
unsigned int | cw = 0 |
camera width | |
unsigned int | ch = 0 |
camera height | |
float | cfps = 0.0F |
camera frame rate in frames/sec | |
unsigned int | uvcformat |
USB-UVC format number (1-based) | |
unsigned int | uvcframe |
USB UVC frame number (1-based) | |
std::string | vendor |
Module creator name, used as a directory to organize the modules. | |
std::string | modulename |
Name of the Module that will process this mapping. | |
WDRtype | wdr = WDRtype::Linear |
Type of wide-dynamic-range (WDR) to use, if sensor supports it. | |
CropType | crop = CropType::Scale |
Type of crop/scale to apply if camera size does not match sensor native. | |
bool | ispython = false |
True if the module is written in Python; affects behavior of sopath() only. | |
unsigned int | c2fmt = 0 |
When crop is CropScale, pixel format of the scaled images, otherwise 0. | |
unsigned int | c2w = 0 |
When crop is CropScale, width of the scaled images, otherwise 0. | |
unsigned int | c2h = 0 |
When crop is CropScale, height of the scaled images, otherwise 0. | |
Related Symbols | |
(Note that these are not member symbols.) | |
JEVOIS_DEFINE_ENUM_CLASS (WDRtype,(Linear)(DOL)) | |
Enum for VideoMapping wide-dynamic-range (WDR) type. | |
JEVOIS_DEFINE_ENUM_CLASS (CropType,(Scale)(Crop)(CropScale)) | |
Enum for VideoMapping crop or rescale. | |
std::ostream & | operator<< (std::ostream &out, VideoMapping const &m) |
Stream a VideoMapping out, intended for machines. | |
std::istream & | operator>> (std::istream &in, VideoMapping &m) |
Stream a VideoMapping in, intended for machines. | |
std::vector< VideoMapping > | loadVideoMappings (CameraSensor s, size_t &defidx, bool checkso=true, bool hasgui=false) |
Load all the video mappings from the default config file. | |
std::vector< VideoMapping > | videoMappingsFromStream (CameraSensor s, std::istream &is, size_t &defidx, bool checkso, bool hasgui) |
Parse all the mappings in a config file and also indicate which one is the default. | |
unsigned int jevois::VideoMapping::c2size | ( | ) | const |
Return the size in bytes of a scaled camera image, if stream==RawAndScaled, otherwise 0.
Definition at line 93 of file VideoMapping.C.
References jevois::v4l2ImageSize().
std::string jevois::VideoMapping::c2str | ( | ) | const |
Convenience function to print out FCC WxH @ fps, for the scaled camera input format, if stream==RawAndScaled.
Definition at line 139 of file VideoMapping.C.
References jevois::fccstr().
std::string jevois::VideoMapping::cmakepath | ( | ) | const |
Return the full absolute path and file name of the module's CMakeLists.txt file.
Definition at line 73 of file VideoMapping.C.
References JEVOIS_MODULE_PATH.
Referenced by jevois::GUIhelper::drawNewModuleForm(), jevois::GUIeditor::refresh(), and jevois::GUIhelper::resetstate().
unsigned int jevois::VideoMapping::csize | ( | ) | const |
Return the size in bytes of a camera image.
Definition at line 89 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 131 of file VideoMapping.C.
References jevois::fccstr().
std::string jevois::VideoMapping::cstrall | ( | ) | const |
Convenience function to print out FCC WxH @ fps plus possibly second stream, for the input (camera) format.
Definition at line 147 of file VideoMapping.C.
|
static |
Convert from fps to USB/UVC interval.
Definition at line 104 of file VideoMapping.C.
Referenced by main().
|
static |
Convert from fps to V4L2 interval.
Definition at line 117 of file VideoMapping.C.
Referenced by jevois::Gadget::setFormat(), and jevois::CameraDevice::setFormat().
bool jevois::VideoMapping::hasSameSpecsAs | ( | VideoMapping const & | other | ) | const |
Equality operator for specs but not vendor or module name.
Note that two mappings will be declared to match if their fps values are within 0.01fps, to avoid mismatches due to floating point representation and rounding.
Definition at line 199 of file VideoMapping.C.
References c2fmt, c2h, c2w, cfmt, cfps, ch, crop, cw, ofmt, ofps, oh, and ow.
Referenced by main().
bool jevois::VideoMapping::isSameAs | ( | VideoMapping const & | other | ) | const |
Equality operator for specs and also vendor or module name.
Note that two mappings will be declared to match if their fps values are within 0.01fps, to avoid mismatches due to floating point representation and rounding.
Definition at line 209 of file VideoMapping.C.
References ispython, modulename, vendor, and wdr.
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 511 of file VideoMapping.C.
Referenced by jevois::Engine::findVideoMapping().
std::string jevois::VideoMapping::menustr | ( | ) | const |
Convenience function to print out the whole mapping in a human-friendly way to be used in a menu.
Definition at line 168 of file VideoMapping.C.
References JEVOISPRO_FMT_GUI.
Referenced by jevois::GUIhelper::drawModuleSelect().
std::string jevois::VideoMapping::menustr2 | ( | ) | const |
Convenience function to print out the whole mapping in a human-friendly way to be used in a menu.
Definition at line 180 of file VideoMapping.C.
References JEVOISPRO_FMT_GUI.
Referenced by jevois::GUIhelper::drawNewModuleForm().
std::string jevois::VideoMapping::modinfopath | ( | ) | const |
Return the full absolute path and file name of the module's modinfo.html file.
Definition at line 79 of file VideoMapping.C.
References JEVOIS_MODULE_PATH.
Referenced by jevois::GUIhelper::drawInfo().
unsigned int jevois::VideoMapping::osize | ( | ) | const |
Return the size in bytes of an output image.
Definition at line 85 of file VideoMapping.C.
References jevois::v4l2ImageSize().
Referenced by jevois::Gadget::setFormat(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::VideoOutputNone::setFormat().
std::string jevois::VideoMapping::ostr | ( | ) | const |
Convenience function to print out FCC WxH @ fps, for the output (UVC) format.
Definition at line 123 of file VideoMapping.C.
References jevois::fccstr().
std::string jevois::VideoMapping::path | ( | ) | const |
Return the full absolute path the module's directory.
Definition at line 30 of file VideoMapping.C.
References JEVOIS_MODULE_PATH, modulename, and vendor.
Referenced by jevois::GUIhelper::drawNewModuleForm(), and jevois::GUIeditor::refresh().
void jevois::VideoMapping::setModuleType | ( | ) |
Determine whether module is C++ or python and set ispython flag accordingly.
The other fields should have been initialized already. operator>> and loadVideoMappings use this function insternally, so no need to call it after making a VideoMapping from sream. This function throws if neither a .so nor .py file is found in the appropriate place given module vendor and name.
Definition at line 519 of file VideoMapping.C.
std::string jevois::VideoMapping::sopath | ( | bool | delete_old_versions = false | ) | const |
Return the full absolute path and file name of the module's .so or .py file.
Definition at line 36 of file VideoMapping.C.
References JEVOIS_MODULE_PATH.
std::string jevois::VideoMapping::srcpath | ( | ) | const |
Return the full absolute path and file name of the module's .C or .py file.
Definition at line 66 of file VideoMapping.C.
References JEVOIS_MODULE_PATH.
Referenced by jevois::GUIhelper::drawNewModuleForm().
std::string jevois::VideoMapping::str | ( | ) | const |
Convenience function to print out the whole mapping in a human-friendly way.
Definition at line 155 of file VideoMapping.C.
Referenced by jevois::GUIhelper::drawNewModuleForm(), and main().
|
static |
Convert from USB/UVC interval to fps.
This function rounds to the nearest 1/100 fps.
Definition at line 97 of file VideoMapping.C.
Referenced by jevois::Engine::getVideoMappingIdx().
|
static |
Convert from V4L2 interval to fps.
This function rounds to the nearest 1/100 fps.
Definition at line 110 of file VideoMapping.C.
|
related |
Enum for VideoMapping crop or rescale.
On JeVois-Pro Platform (only), the camera ISP can stream up to two images: 1) the raw frame from the sensor (possibly cropped), 2) a scaled frame generated by the ISP (scaling is always applied to the native sensor resolution, irrespective of crop settings), or both. The images can have different pixel types but same frames/s. Getting both cropped and scaled images is useful to use a full-frame raw YUYV capture for GUI display, plus a scaled down RGB24 capture as input to a neural network. When a camera frame size is specified which does not match the sensor's size, either do a centered crop, or a uniform rescaling. Note that rescaling can affect the image aspect ratio, and thus it is recommended that camera frame sizes with same aspect ratio at the native sensor size be used. If nothing is specified in a VideoMapping, use Scale as default.
|
related |
Enum for VideoMapping wide-dynamic-range (WDR) type.
If nothing is specified in a VideoMapping, use Linear by default.
|
related |
Load all the video mappings from the default config file.
|
related |
Stream a VideoMapping out, intended for machines.
Note that no std::endl is issued at the end.
|
related |
Stream a VideoMapping in, intended for machines.
Note that the assumption is that the mapping is clean (no extra garbage).
|
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).
The camera format field can have colon-separated prefixes for qualifiers that specify WDR (wide-dynamic-range) camera capture mode and/or crop vs. rescale behavior when camera input dims do not match sensor native dims (only effective on JeVois-Pro).
The output width and height can be wither absolute, or relative to camera width and height if prefixed with a + or
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
unsigned int jevois::VideoMapping::c2fmt = 0 |
When crop is CropScale, pixel format of the scaled images, otherwise 0.
Definition at line 84 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), and jevois::Camera::setFormat().
unsigned int jevois::VideoMapping::c2h = 0 |
When crop is CropScale, height of the scaled images, otherwise 0.
Definition at line 86 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), and jevois::Camera::setFormat().
unsigned int jevois::VideoMapping::c2w = 0 |
When crop is CropScale, width of the scaled images, otherwise 0.
Definition at line 85 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), and jevois::Camera::setFormat().
unsigned int jevois::VideoMapping::cfmt = 0 |
camera pixel format
Definition at line 68 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), main(), and jevois::Camera::setFormat().
float jevois::VideoMapping::cfps = 0.0F |
camera frame rate in frames/sec
Definition at line 71 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), main(), and jevois::Camera::setFormat().
unsigned int jevois::VideoMapping::ch = 0 |
camera height
Definition at line 70 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), main(), and jevois::Camera::setFormat().
CropType jevois::VideoMapping::crop = CropType::Scale |
Type of crop/scale to apply if camera size does not match sensor native.
Definition at line 81 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), and jevois::Camera::setFormat().
unsigned int jevois::VideoMapping::cw = 0 |
camera width
Definition at line 69 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), main(), and jevois::Camera::setFormat().
bool jevois::VideoMapping::ispython = false |
True if the module is written in Python; affects behavior of sopath() only.
Definition at line 82 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), isSameAs(), and jevois::PythonModule::PythonModule().
std::string jevois::VideoMapping::modulename |
Name of the Module that will process this mapping.
Definition at line 78 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawInfo(), jevois::GUIhelper::drawNewModuleForm(), isSameAs(), main(), and path().
unsigned int jevois::VideoMapping::ofmt = 0 |
output pixel format, or 0 for no output over USB
Definition at line 63 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawModuleSelect(), jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), jevois::Gadget::setFormat(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::VideoOutputNone::setFormat().
float jevois::VideoMapping::ofps = 0.0F |
output frame rate in frames/sec
Definition at line 66 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), jevois::Engine::getVideoMappingIdx(), hasSameSpecsAs(), jevois::Gadget::setFormat(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::VideoOutputNone::setFormat().
unsigned int jevois::VideoMapping::oh = 0 |
output height
Definition at line 65 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), jevois::Gadget::setFormat(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::VideoOutputNone::setFormat().
unsigned int jevois::VideoMapping::ow = 0 |
output width
Definition at line 64 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), hasSameSpecsAs(), jevois::Gadget::setFormat(), jevois::VideoDisplayGL::setFormat(), jevois::VideoDisplayGUI::setFormat(), and jevois::VideoOutputNone::setFormat().
unsigned int jevois::VideoMapping::uvcformat |
USB-UVC format number (1-based)
Definition at line 73 of file VideoMapping.H.
Referenced by jevois::Engine::getVideoMappingIdx().
unsigned int jevois::VideoMapping::uvcframe |
USB UVC frame number (1-based)
Definition at line 74 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 76 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), isSameAs(), main(), and path().
WDRtype jevois::VideoMapping::wdr = WDRtype::Linear |
Type of wide-dynamic-range (WDR) to use, if sensor supports it.
Definition at line 80 of file VideoMapping.H.
Referenced by jevois::GUIhelper::drawNewModuleForm(), isSameAs(), and main().