YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::sig::utils Namespace Reference

Classes

struct  PCL_ROI
 

Enumerations

enum class  RotateOption {
  rotate_cw ,
  rotate_ccw ,
  rotate_180 ,
  rotate_none
}
 
enum class  FlipOption {
  flip_x ,
  flip_y ,
  flip_xy ,
  flip_none
}
 
enum class  OrganizationType {
  Organized ,
  Unorganized
}
 

Functions

bool vertSplit (const yarp::sig::Image &inImg, yarp::sig::Image &outImgL, yarp::sig::Image &outImgR)
 Split vertically an image in two images of the same size.
 
bool horzSplit (const yarp::sig::Image &inImg, yarp::sig::Image &outImgUp, yarp::sig::Image &outImgDown)
 Split horizontally an image in two images of the same size.
 
bool horzConcat (const yarp::sig::Image &inImgL, const yarp::sig::Image &inImgR, yarp::sig::Image &outImg)
 Concatenate horizontally two images of the same size in one with double width.
 
bool vertConcat (const yarp::sig::Image &inImgUp, const yarp::sig::Image &inImgDown, yarp::sig::Image &outImg)
 Concatenate vertically two images of the same size in one with double height.
 
bool cropRect (const yarp::sig::Image &inImg, const std::pair< unsigned int, unsigned int > &vertex1, const std::pair< unsigned int, unsigned int > &vertex2, yarp::sig::Image &outImg)
 Crop a rectangle area out of an image given two opposite vertices.
 
bool sum (yarp::sig::Image &OutImg, const yarp::sig::Image &InImg, bool colorkey_enable, int colorkey, bool alpha_enable, float alpha, size_t off_x, size_t off_y)
 applies an image on the top over another image.
 
bool rotate (yarp::sig::Image &OutImg, const yarp::sig::Image &InImg, RotateOption rotateflag=RotateOption::rotate_none, FlipOption flipflag=FlipOption::flip_none)
 Rotate and/or flip an image.
 
yarp::sig::PointCloud< yarp::sig::DataXYZ > depthToPC (const yarp::sig::ImageOf< yarp::sig::PixelFloat > &depth, const yarp::sig::IntrinsicParams &intrinsic)
 depthToPC, compute the PointCloud given depth image and the intrinsic parameters of the camera.
 
yarp::sig::PointCloud< yarp::sig::DataXYZ > depthToPC (const yarp::sig::ImageOf< yarp::sig::PixelFloat > &depth, const yarp::sig::IntrinsicParams &intrinsic, const yarp::sig::utils::PCL_ROI &roi, size_t step_x=1, size_t step_y=1, const std::string &output_order="+X+Y+Z")
 depthToPC, compute the PointCloud given depth image, the intrinsic parameters of the camera and a Region Of Interest.
 
template<typename T1 , typename T2 >
yarp::sig::PointCloud< T1 > depthRgbToPC (const yarp::sig::ImageOf< yarp::sig::PixelFloat > &depth, const yarp::sig::ImageOf< T2 > &color, const yarp::sig::IntrinsicParams &intrinsic, const yarp::sig::utils::OrganizationType organizationType=yarp::sig::utils::OrganizationType::Organized, size_t step_x=1, size_t step_y=1, const std::string &output_order="+X+Y+Z")
 depthRgbToPC, compute the colored PointCloud given depth image, color image and the intrinsic parameters of the camera.
 
bool makeSawTooth (Sound &outSound, double duration_s=1.0, size_t channels=1, size_t sampleRate=16000, double frequency=1, size_t amplitude=30000)
 Generate a sound containing a sawtooth signal.
 
bool makeTone (Sound &outSound, double duration_s=1.0, size_t channels=1, size_t sampleRate=16000, double frequency=440, size_t amplitude=30000)
 Generate a sound containing a sine wave tone.
 
bool makeSquareWave (Sound &outSound, double duration_s=1.0, size_t channels=1, size_t sampleRate=16000, double frequency=1, size_t amplitude=30000)
 Generate a sound containing a square wave signal.
 
Sound mix (const Sound &A, const Sound &B, double percentage)
 Mixes two sounds together into a single sound.
 

Enumeration Type Documentation

◆ FlipOption

enum class yarp::sig::utils::FlipOption
strong
Enumerator
flip_x 
flip_y 
flip_xy 
flip_none 

Definition at line 99 of file ImageUtils.h.

◆ OrganizationType

Enumerator
Organized 
Unorganized 

Definition at line 15 of file PointCloudUtils.h.

◆ RotateOption

enum class yarp::sig::utils::RotateOption
strong
Enumerator
rotate_cw 
rotate_ccw 
rotate_180 
rotate_none 

Definition at line 91 of file ImageUtils.h.

Function Documentation

◆ cropRect()

bool yarp::sig::utils::cropRect ( const yarp::sig::Image &  inImg,
const std::pair< unsigned int, unsigned int > &  vertex1,
const std::pair< unsigned int, unsigned int > &  vertex2,
yarp::sig::Image &  outImg 
)

Crop a rectangle area out of an image given two opposite vertices.

Parameters
[in]inImginput image.
[in]vertex1first vertex of the crop rectangle area.
[in]vertex2second vertex of the crop rectangle area.
[out]outImgresult of cropping the input image.
Note
Input and output images must have same pixel type and the crop area must lay within the input image. Vertices needn't be passed in the usual top-left, bottom-right order. The output image is resized to match the crop dimensions.
Returns
true on success, false otherwise.

Definition at line 122 of file ImageUtils.cpp.

◆ depthRgbToPC()

template<typename T1 , typename T2 >
yarp::sig::PointCloud< T1 > yarp::sig::utils::depthRgbToPC ( const yarp::sig::ImageOf< yarp::sig::PixelFloat > &  depth,
const yarp::sig::ImageOf< T2 > &  color,
const yarp::sig::IntrinsicParams &  intrinsic,
const yarp::sig::utils::OrganizationType  organizationType = yarp::sig::utils::OrganizationType::Organized,
size_t  step_x = 1,
size_t  step_y = 1,
const std::string &  output_order = "+X+Y+Z" 
)

depthRgbToPC, compute the colored PointCloud given depth image, color image and the intrinsic parameters of the camera.

Parameters
[in]depth,theinput depth image.
[in]color,theinput color image.
[in]intrinsic,intrinsicparameter of the camera.
[in]organizationType,iforganized the point cloud has size (width, depth). if unorganized the point cloud has size (width*height, 1). Note that in this case the data are organized column-wise (i.e. y,x and not x,y)
[in]step_x,thedepth image size can be decimated, by selecting a column every step_x;
[in]step_y,thedepth image size can be decimated, by selecting a row every step_y;
[in]output_order,thestring will optionally rearrange data in any combination of positive and negative axes. e.g. "+Z-Y+X". Useful when dealing with not right-handed coordinate systems. Optimized for efficiency during point cloud creation with no additional computation.
Note
the intrinsic parameters are the one of the depth sensor if the depth frame IS NOT aligned with the colored one. On the other hand use the intrinsic parameters of the RGB camera if the frames are aligned.
Returns
the point cloud obtained by the de-projection.

Definition at line 62 of file PointCloudUtils-inl.h.

◆ depthToPC() [1/2]

PointCloud< DataXYZ > yarp::sig::utils::depthToPC ( const yarp::sig::ImageOf< yarp::sig::PixelFloat > &  depth,
const yarp::sig::IntrinsicParams &  intrinsic 
)

depthToPC, compute the PointCloud given depth image and the intrinsic parameters of the camera.

Parameters
[in]depth,theinput depth image.
[in]intrinsic,intrinsicparameter of the camera.
Note
the intrinsic parameters are the one of the depth sensor if the depth frame IS NOT aligned with the colored one. On the other hand use the intrinsic parameters of the RGB camera if the frames are aligned.
Returns
the point cloud obtained by the de-projection.

Definition at line 16 of file PointCloudUtils.cpp.

◆ depthToPC() [2/2]

PointCloud< DataXYZ > yarp::sig::utils::depthToPC ( const yarp::sig::ImageOf< yarp::sig::PixelFloat > &  depth,
const yarp::sig::IntrinsicParams &  intrinsic,
const yarp::sig::utils::PCL_ROI &  roi,
size_t  step_x = 1,
size_t  step_y = 1,
const std::string &  output_order = "+X+Y+Z" 
)

depthToPC, compute the PointCloud given depth image, the intrinsic parameters of the camera and a Region Of Interest.

Parameters
[in]depth,theinput depth image.
[in]intrinsic,intrinsicparameter of the camera.
[in]roi,theRegion Of Interest intrinsic of the depth image that we want to convert.
[in]step_x,thedepth image size can be decimated, by selecting a column every step_x;
[in]step_y,thedepth image size can be decimated, by selecting a row every step_y;
[in]output_order,thestring will optionally rearrange data in any combination of positive and negative axes. e.g. "+Z-Y+X". Useful when dealing with not right-handed coordinate systems. Optimized for efficiency during point cloud creation with no additional computation.
Note
the intrinsic parameters are the one of the depth sensor if the depth frame IS NOT aligned with the colored one. On the other hand use the intrinsic parameters of the RGB camera if the frames are aligned.
Returns
the point cloud obtained by the de-projection.

Definition at line 40 of file PointCloudUtils.cpp.

◆ horzConcat()

bool yarp::sig::utils::horzConcat ( const yarp::sig::Image &  inImgL,
const yarp::sig::Image &  inImgR,
yarp::sig::Image &  outImg 
)

Concatenate horizontally two images of the same size in one with double width.

Parameters
[in]inImgLinput left image.
[in]inImgRinput right image.
[out]outImgresult of the horizontal concatenation.
Note
The input images must have same dimensions and pixel type, and the output image must have same height and double width.
Returns
true on success, false otherwise.

Definition at line 76 of file ImageUtils.cpp.

◆ horzSplit()

bool yarp::sig::utils::horzSplit ( const yarp::sig::Image &  inImg,
yarp::sig::Image &  outImgUp,
yarp::sig::Image &  outImgDown 
)

Split horizontally an image in two images of the same size.

Parameters
[in]inImgimage to be horizontally split.
[out]outImgUptop half of inImg.
[out]outImgDownbottom half of inImg.
Note
The input image must have same height, double width of the output images and same pixel type.
Returns
true on success, false otherwise.

Definition at line 59 of file ImageUtils.cpp.

◆ makeSawTooth()

bool yarp::sig::utils::makeSawTooth ( Sound &  outSound,
double  duration_s = 1.0,
size_t  channels = 1,
size_t  sampleRate = 16000,
double  frequency = 1,
size_t  amplitude = 30000 
)

Generate a sound containing a sawtooth signal.

Parameters
[out]outSoundThe generated sound.
[in]duration_sDuration of the tone in seconds.
[in]channelsNumber of channels for the sound.
[in]sampleRateThe sample rate of the sound in Hz.
[in]frequencyThe frequency of the generated sawtooth signal in Hz
[in]amplitudeThe amplitude of the generated sawtooth signal (max ~32767 for 16-bit)
Returns
true on success, false otherwise.

Definition at line 38 of file SoundUtils.cpp.

◆ makeSquareWave()

bool yarp::sig::utils::makeSquareWave ( Sound &  outSound,
double  duration_s = 1.0,
size_t  channels = 1,
size_t  sampleRate = 16000,
double  frequency = 1,
size_t  amplitude = 30000 
)

Generate a sound containing a square wave signal.

Parameters
[out]outSoundThe generated sound.
[in]duration_sDuration of the tone in seconds.
[in]channelsNumber of channels for the sound.
[in]sampleRateThe sample rate of the sound in Hz.
[in]frequencyThe frequency of the generated square wave signal in Hz (default = 1Hz)
[in]amplitudeThe amplitude of the generated square wave signal (max ~32767 for 16-bit)
Returns
true on success, false otherwise.

Definition at line 58 of file SoundUtils.cpp.

◆ makeTone()

bool yarp::sig::utils::makeTone ( Sound &  outSound,
double  duration_s = 1.0,
size_t  channels = 1,
size_t  sampleRate = 16000,
double  frequency = 440,
size_t  amplitude = 30000 
)

Generate a sound containing a sine wave tone.

Parameters
[out]outSoundThe generated sound.
[in]duration_sDuration of the tone in seconds.
[in]channelsNumber of channels for the sound.
[in]sampleRateThe sample rate of the sound in Hz.
[in]frequencyThe frequency of the generated tone in Hz (default = 440Hz A4)
[in]amplitudeThe amplitude of the generated tone (max ~32767 for 16-bit)
Returns
true on success, false otherwise.

Definition at line 80 of file SoundUtils.cpp.

◆ mix()

Sound yarp::sig::utils::mix ( const Sound &  A,
const Sound &  B,
double  percentage 
)

Mixes two sounds together into a single sound.

This function combines the audio of two sounds with the same number of channels and sample rate. If the sounds have different durations, silence will be added to the shorter one to match the length of the longer sound before mixing.

The percentage parameter controls the relative loudness of the two sounds in the mix. For example, if percentage is 0.7, the resulting sound will consist of 70% of the first sound (A) and 30% of the second sound (B).

The resulting mixed sound is returned as a new Sound object. The original sounds (A and B) are not modified.

Parameters
AThe first sound to mix.
BThe second sound to mix.
percentageThe weight of the first sound in the mix (between 0.0 and 1.0). The second sound will have a weight of (1 - percentage).
Returns
A new Sound object containing the mixed audio.
Exceptions
std::runtime_errorIf the sounds have different sample rates or channel counts.

Definition at line 99 of file SoundUtils.cpp.

◆ rotate()

bool yarp::sig::utils::rotate ( yarp::sig::Image &  OutImg,
const yarp::sig::Image &  InImg,
RotateOption  rotateflag = RotateOption::rotate_none,
FlipOption  flipflag = FlipOption::flip_none 
)

Rotate and/or flip an image.

Parameters
[in]InImginput image.
[out]OutImgresult of the rotation and/or flip operation.
[in]rotateflagrotation option. Default is no rotation.
[in]flipflagflip option. Default is no flip.
Note
Input and output images must have same pixel type. The output image is resized to match the rotated/flipped dimensions.
Returns
true on success, false otherwise.

Definition at line 217 of file ImageUtils.cpp.

◆ sum()

bool yarp::sig::utils::sum ( yarp::sig::Image &  OutImg,
const yarp::sig::Image &  InImg,
bool  colorkey_enable,
int  colorkey,
bool  alpha_enable,
float  alpha,
size_t  off_x,
size_t  off_y 
)

applies an image on the top over another image.

Currently it is implemented only for RGB Images

Parameters
[in/out]OutImg the output image. It must be a valid image on the top of which data will be summed. It may contain a background or it can be zero.
[in]InImgthe layer to be applied
[in]colorkeycolorkey for the InImg image. If a pixel is == colorkey, then it will be made transparent and the background will be visible.
[in]alphato be applied to InImg.
[in]off_xhorizontal offset applied to InImg. Excess will be cropped.
[in]off_yvertical offset applied to InImg. Excess will be cropped.
Note
The two images must have the same pixelCode.
Returns
true on success, false if image cannot be summed because of incompatible format.

Definition at line 154 of file ImageUtils.cpp.

◆ vertConcat()

bool yarp::sig::utils::vertConcat ( const yarp::sig::Image &  inImgUp,
const yarp::sig::Image &  inImgDown,
yarp::sig::Image &  outImg 
)

Concatenate vertically two images of the same size in one with double height.

Parameters
[in]inImgUpinput top image.
[in]inImgDowninput bottom image.
[out]outImgresult of the horizontal concatenation.
Note
The input images must have same dimensions and pixel type, and the output image must have same width and double height.
Returns
true on success, false otherwise.

Definition at line 107 of file ImageUtils.cpp.

◆ vertSplit()

bool yarp::sig::utils::vertSplit ( const yarp::sig::Image &  inImg,
yarp::sig::Image &  outImgL,
yarp::sig::Image &  outImgR 
)

Split vertically an image in two images of the same size.

Parameters
[in]inImgimage to be vertically split.
[out]outImgLleft half of inImg.
[out]outImgRright half of inImg.
Note
The input image must have same height, double width of the output images and same pixel type.
Returns
true on success, false otherwise.

Definition at line 32 of file ImageUtils.cpp.