Skip to content

usb_cam::formats

Classes

Name
class usb_cam::formats::pixel_format_base
Base pixel format class. Provide all necessary information for converting between V4L2 and ROS formats. Meant to be overridden if conversion function is required.
struct usb_cam::formats::format_arguments_t
Helper structure to standardize all pixel_format_base constructors, so that they all have the same argument type.
class usb_cam::formats::default_pixel_format
class usb_cam::formats::YUYV2RGB
class usb_cam::formats::YUYV
class usb_cam::formats::Y102MONO8
Also known as MONO10 to MONO8.
class usb_cam::formats::UYVY2RGB
class usb_cam::formats::UYVY
class usb_cam::formats::RGB8
class usb_cam::formats::RAW_MJPEG
class usb_cam::formats::MONO8
class usb_cam::formats::MONO16
class usb_cam::formats::MJPEG2RGB
class usb_cam::formats::M4202RGB

Functions

Name
std::string get_ros_pixel_format_from_av_format(const AVPixelFormat & avPixelFormat)
Get ROS PixelFormat from AVPixelFormat.
std::string get_ros_pixel_format_from_av_format(const std::string avPixelFormatStr)
Overload to support av pixel formats being passed as strings.
uint8_t get_channels_from_av_format(const AVPixelFormat & avPixelFormat)
Get the number of channels from AVPixelFormat.
uint8_t get_channels_from_av_format(const std::string & avPixelFormatStr)
Overload of function below to support av pixel formats as strings.
uint8_t get_bit_depth_from_av_format(const AVPixelFormat & avPixelFormat)
Get the pixel bit depth from AVPixelFormat.
uint8_t get_bit_depth_from_av_format(const std::string & avPixelFormatStr)
Overload of function below to support passing av pixel formats as strings.
AVPixelFormat get_av_pixel_format_from_string(const std::string & str)
Get AVPixelFormat from string. This string should correspond to the AVPixelFormat name. The name can either be given with or without the 'AV_PIX_FMT_' prefix.
void YUV2RGB(const unsigned char & y, const unsigned char & u, const unsigned char & v, unsigned char * r, unsigned char * g, unsigned char * b)
Conversion from YUV to RGB.
unsigned char CLIPVALUE(const int & val)

Attributes

Name
const std::unordered_map< std::string, AVPixelFormat > STR_2_AVPIXFMT
Map to associate string of pixel format name to actual pixel format enum.

Functions Documentation

function get_ros_pixel_format_from_av_format

inline std::string get_ros_pixel_format_from_av_format(
    const AVPixelFormat & avPixelFormat
)

Get ROS PixelFormat from AVPixelFormat.

Parameters:

  • avPixelFormat AVPixelFormat

Return: String specifying the ROS pixel format.

function get_ros_pixel_format_from_av_format

inline std::string get_ros_pixel_format_from_av_format(
    const std::string avPixelFormatStr
)

Overload to support av pixel formats being passed as strings.

Parameters:

  • avPixelFormat AvPixelFormat as string

Return: String specifying the ROS pixel format.

function get_channels_from_av_format

inline uint8_t get_channels_from_av_format(
    const AVPixelFormat & avPixelFormat
)

Get the number of channels from AVPixelFormat.

Parameters:

  • avPixelFormat AVPixelFormat

Return: Number of channels as uint8

function get_channels_from_av_format

inline uint8_t get_channels_from_av_format(
    const std::string & avPixelFormatStr
)

Overload of function below to support av pixel formats as strings.

Parameters:

  • avPixelFormatStr AvPixelFormat as string

Return: Number of channels as uint8_t

function get_bit_depth_from_av_format

inline uint8_t get_bit_depth_from_av_format(
    const AVPixelFormat & avPixelFormat
)

Get the pixel bit depth from AVPixelFormat.

Parameters:

  • avPixelFormat AVPixelFormat

Return: Bit depth as uint8

function get_bit_depth_from_av_format

inline uint8_t get_bit_depth_from_av_format(
    const std::string & avPixelFormatStr
)

Overload of function below to support passing av pixel formats as strings.

Parameters:

  • avPixelFormatStr AVPixelFormat as string

Return: Bit depth as uint8

function get_av_pixel_format_from_string

inline AVPixelFormat get_av_pixel_format_from_string(
    const std::string & str
)

Get AVPixelFormat from string. This string should correspond to the AVPixelFormat name. The name can either be given with or without the 'AV_PIX_FMT_' prefix.

Parameters:

  • str AVPixelFormat name

Return: Pixel format enum corresponding to a given name

function YUV2RGB

inline void YUV2RGB(
    const unsigned char & y,
    const unsigned char & u,
    const unsigned char & v,
    unsigned char * r,
    unsigned char * g,
    unsigned char * b
)

Conversion from YUV to RGB.

The normal conversion matrix is due to Julien (surname unknown):

[ R ] [ 1.0 0.0 1.403 ] [ Y ] [ G ] = [ 1.0 -0.344 -0.714 ] [ U ] [ B ] [ 1.0 1.770 0.0 ] [ V ]

and the firewire one is similar:

[ R ] [ 1.0 0.0 0.700 ] [ Y ] [ G ] = [ 1.0 -0.198 -0.291 ] [ U ] [ B ] [ 1.0 1.015 0.0 ] [ V ]

Corrected by BJT (coriander's transforms RGB->YUV and YUV->RGB do not get you back to the same RGB!) [ R ] [ 1.0 0.0 1.136 ] [ Y ] [ G ] = [ 1.0 -0.396 -0.578 ] [ U ] [ B ] [ 1.0 2.041 0.002 ] [ V ]

function CLIPVALUE

inline unsigned char CLIPVALUE(
    const int & val
)

Clip a value to the range 0<val<255. For speed this is done using an array, so can only cope with numbers in the range -128<=val<=383.

Attributes Documentation

variable STR_2_AVPIXFMT

const std::unordered_map< std::string, AVPixelFormat > STR_2_AVPIXFMT;

Map to associate string of pixel format name to actual pixel format enum.


Updated on 2024-05-01 at 16:56:02 +0000