vision
Public Member Functions | Protected Attributes | List of all members
roboticslab::Travis Class Reference

The Travis class implements all the algorithms on a single image.

#include <TravisLib.hpp>

Public Member Functions

 Travis (bool quiet=true, bool overwrite=true)
 
bool setCvMat (const cv::Mat &image)
 
bool setBinCvMat (const cv::Mat &image)
 
bool binarize (const char *algorithm)
 
bool binarize (const char *algorithm, const double &threshold)
 
bool binarize (const char *algorithm, const double &min, const double &max)
 
void morphClosing (const int &closure)
 
void morphOpening (const int &opening)
 
int blobize (const int &maxNumBlobs)
 
void pushContour (const std::vector< cv::Point > &contour)
 
bool getBlobsXY (std::vector< cv::Point2d > &locations)
 
bool getBlobsArea (std::vector< double > &areas)
 
bool getBlobsSolidity (std::vector< double > &solidities)
 
bool getBlobsRect (std::vector< cv::Rect > &rects)
 
bool getBlobsAngle (const int &method, std::vector< double > &angles)
 
bool getBlobsAspectRatio (std::vector< double > &aspectRatios, std::vector< double > &axisFirsts, std::vector< double > &axisSeconds)
 
bool getBlobsPerimeter (std::vector< double > &perimeters)
 
bool getBlobsRectangularity (std::vector< double > &rectangularities)
 
bool getBlobsHSV (std::vector< double > &hues, std::vector< double > &vals, std::vector< double > &sats, std::vector< double > &hueStdDevs, std::vector< double > &valStdDevs, std::vector< double > &satStdDevs)
 
cv::Mat & getCvMat (const int &image, const int &vizualization)
 
void release ()
 

Protected Attributes

bool _quiet
 
bool _overwrite
 
cv::Mat _img
 
cv::Mat _imgHsv
 
cv::Mat _imgBin
 
cv::Mat _imgBin3
 
std::vector< std::vector< cv::Point > > _contours
 
std::vector< cv::RotatedRect > _minRotatedRects
 

Constructor & Destructor Documentation

◆ Travis()

roboticslab::Travis::Travis ( bool  quiet = true,
bool  overwrite = true 
)
inline

Travis class constructor.

Parameters
quietsuppress messages displayed upon success/failure.
overwritewill not make a copy (faster, less memory), but will overwrite the image you pass.

Member Function Documentation

◆ binarize() [1/3]

bool roboticslab::Travis::binarize ( const char *  algorithm)

Binarize the image.

Parameters
algorithmimplemented: "redMinusGreen", "greenMinusRed".

◆ binarize() [2/3]

bool roboticslab::Travis::binarize ( const char *  algorithm,
const double &  min,
const double &  max 
)

Binarize the image.

Parameters
algorithmimplemented: "redMinusGreen", "greenMinusRed".
mini.e. 110.
maxi.e. 130.

◆ binarize() [3/3]

bool roboticslab::Travis::binarize ( const char *  algorithm,
const double &  threshold 
)

Binarize the image.

Parameters
algorithmimplemented: "redMinusGreen", "greenMinusRed".
thresholdi.e. 50.

◆ blobize()

int roboticslab::Travis::blobize ( const int &  maxNumBlobs)

Use findContours to get what we use as blobs.

Parameters
maxNumBlobsthe number of max blobs to keep, the rest get truncated.
Returns
number of blobs detected (can be 0), truncated by maxNumBlobs.

◆ getBlobsAngle()

bool roboticslab::Travis::getBlobsAngle ( const int &  method,
std::vector< double > &  angles 
)

This function calculates ALPHA, and _minRotatedRects as a side effect.

Parameters
method0=box, 1=ellipse.
anglesreturned.

◆ getBlobsArea()

bool roboticslab::Travis::getBlobsArea ( std::vector< double > &  areas)

This function calculates the Area of the blobs (contours).

Parameters
areasreturned.

◆ getBlobsAspectRatio()

bool roboticslab::Travis::getBlobsAspectRatio ( std::vector< double > &  aspectRatios,
std::vector< double > &  axisFirsts,
std::vector< double > &  axisSeconds 
)

This function calculates the Aspect Ratios and Axes of the stored _minRotatedRects.

Parameters
aspectRatiosreturned.
axisFirstsreturned.
axisSecondsreturned.

◆ getBlobsHSV()

bool roboticslab::Travis::getBlobsHSV ( std::vector< double > &  hues,
std::vector< double > &  vals,
std::vector< double > &  sats,
std::vector< double > &  hueStdDevs,
std::vector< double > &  valStdDevs,
std::vector< double > &  satStdDevs 
)

This function calculates HSV Means and Standard Deviations.

Parameters
huesreturned.
valsreturned.
satsreturned.
hueStdDevsreturned.
valStdDevsreturned.
satStdDevsreturned.

◆ getBlobsRectangularity()

bool roboticslab::Travis::getBlobsRectangularity ( std::vector< double > &  rectangularities)

This function calculates the Rectangularities of the stored _minRotatedRects.

Parameters
rectangularitiesreturned.

◆ getBlobsSolidity()

bool roboticslab::Travis::getBlobsSolidity ( std::vector< double > &  solidities)

This function calculates the Solidity of the blobs (contours).

Parameters
soliditiesreturned.

◆ getBlobsXY()

bool roboticslab::Travis::getBlobsXY ( std::vector< cv::Point2d > &  locations)

This function calculates X and Y as moments directly extracted from the stored contours.

Parameters
locationsreturned.

◆ getCvMat()

cv::Mat & roboticslab::Travis::getCvMat ( const int &  image,
const int &  vizualization 
)

Get the image in cv::Mat format.

Parameters
image
vizualizationparam, 0=None,1=Box,2=Contour,3=Both.
Returns
the image, in cv::Mat format.

◆ morphClosing()

void roboticslab::Travis::morphClosing ( const int &  closure)

Morphologically closing the binarized image.

Parameters
closurei.e. 4 for a 100x100 image, 15 for higher resolution.

◆ morphOpening()

void roboticslab::Travis::morphOpening ( const int &  opening)

Morphologically opening the binarized image.

Parameters
openingi.e. 4 for a 100x100 image, 15 for higher resolution.

◆ pushContour()

void roboticslab::Travis::pushContour ( const std::vector< cv::Point > &  contour)

Push a contour.

Parameters
contourto be pushed on to the stack. Use with care.

◆ release()

void roboticslab::Travis::release ( )

Release _img and _imgBin3 to prevent memory leaks.

◆ setBinCvMat()

bool roboticslab::Travis::setBinCvMat ( const cv::Mat &  image)

Set the image in cv::Mat format.

Parameters
imagethe image to set, in cv::Mat format.
Returns
true if the object was set successfully.

◆ setCvMat()

bool roboticslab::Travis::setCvMat ( const cv::Mat &  image)

Set the image in cv::Mat format.

Parameters
imagethe image to set, in cv::Mat format.
Returns
true if the object was set successfully.

Member Data Documentation

◆ _contours

std::vector<std::vector<cv::Point> > roboticslab::Travis::_contours
protected

Store the contours (blob contours).

◆ _img

cv::Mat roboticslab::Travis::_img
protected

Store the image in cv::Mat format.

◆ _imgBin

cv::Mat roboticslab::Travis::_imgBin
protected

Store the binary image in cv::Mat format.

◆ _imgBin3

cv::Mat roboticslab::Travis::_imgBin3
protected

Store the binary image fit for 3 layer sending in cv::Mat format.

◆ _imgHsv

cv::Mat roboticslab::Travis::_imgHsv
protected

Store the hsv image in cv::Mat format.

◆ _minRotatedRects

std::vector<cv::RotatedRect> roboticslab::Travis::_minRotatedRects
protected

Store the box.

◆ _overwrite

bool roboticslab::Travis::_overwrite
protected

Store the overwrite parameter.

◆ _quiet

bool roboticslab::Travis::_quiet
protected

Store the verbosity level.


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