Companion  1.0.0
Companion is an object recognition framework written with OpenCV.
Static Public Member Functions | List of all members
Companion::Util Class Reference

#include <Util.h>

Static Public Member Functions

static cv::Mat CutImage (cv::Mat img, cv::Rect cutArea)
 
static bool IsImageLoaded (const cv::Mat &img)
 
static void ResizeImage (cv::Mat &img, SCALING scaling)
 
static void ResizeImage (cv::Mat &img, cv::Size size)
 
static void ResizeImage (cv::Mat &img, int width)
 
static void RatioPosition (cv::Point &point, int cWidth, int cHeight, int nWidth, int nHeight)
 
static bool ValidateShape (cv::Point2f topRight, cv::Point2f bottomLeft, cv::Point2f topLeft, cv::Point2f bottomRight, int minSidelLength=10, float maxSideDeviation=0.5f, float maxDiagonalDeviation=0.1f)
 
static void ConvertColor (cv::Mat &src, cv::Mat &dst, ColorFormat colorFormat)
 

Detailed Description

Utility class for Companion.

Author
Andreas Sekulksi, Dimitri Kotlovsky

Member Function Documentation

◆ ConvertColor()

void Companion::Util::ConvertColor ( cv::Mat &  src,
cv::Mat &  dst,
Companion::ColorFormat  colorFormat 
)
static

Convert an image to the given color format. BGR is expected as source format.

Parameters
srcSource image.
dstDestination image.
colorFormatColor format for the converted image.

◆ CutImage()

cv::Mat Companion::Util::CutImage ( cv::Mat  img,
cv::Rect  cutArea 
)
static

Cut the given area out of the given image.

Parameters
imgSource image.
cutAreaArea to cut out.
Returns
Cut out image.

◆ IsImageLoaded()

bool Companion::Util::IsImageLoaded ( const cv::Mat &  img)
static

Check if given image is loaded.

Parameters
imgImage to check if it is not null.
Returns
True if image is loaded, false otherwise.

◆ RatioPosition()

void Companion::Util::RatioPosition ( cv::Point &  point,
int  cWidth,
int  cHeight,
int  nWidth,
int  nHeight 
)
static

Recalculate the coordinates of the given point from current image dimensions to new given dimensions.

Parameters
pointPoint the coordinates of which should be recalculated.
cWidthCurrent width.
cHeightCurrent height.
nWidthNew width.
nHeightNew height.

◆ ResizeImage() [1/3]

void Companion::Util::ResizeImage ( cv::Mat &  img,
SCALING  scaling 
)
static

Resize given image.

Parameters
imgImage to resize.
scalingScaling factor to resize.

◆ ResizeImage() [2/3]

void Companion::Util::ResizeImage ( cv::Mat &  img,
cv::Size  size 
)
static

Resize given image.

Parameters
imgImage to resize.
sizeWidth and height in pixels to resize image.

◆ ResizeImage() [3/3]

void Companion::Util::ResizeImage ( cv::Mat &  img,
int  width 
)
static

Resize given image to given width (keeps aspect ratio).

Parameters
imgImage to resize.
widthImage width in pixels.

◆ ValidateShape()

bool Companion::Util::ValidateShape ( cv::Point2f  topRight,
cv::Point2f  bottomLeft,
cv::Point2f  topLeft,
cv::Point2f  bottomRight,
int  minSidelLength = 10,
float  maxSideDeviation = 0.5f,
float  maxDiagonalDeviation = 0.1f 
)
static

Validate the rectangular shape of a recognized area.

Parameters
topRightTop right corner of the recognized area.
bottomLeftBottom left corner of the recognized area.
topLeftTop left corner of the recognized area.
bottomRightBottom right corner of the recognized area.
minSidelLengthMinimum length of the recognized area's sides (in pixels).
maxSideDeviationMaximum deviation of the sides' lengths.
maxDiagonalDeviationMaximum deviation of the diagonals' lengths.
Returns
True if the diagonals are long enough and both have a similar length, otherwise false.

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