The Travis class implements all the algorithms on a single image.
#include <TravisLib.hpp>
|
| 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 () |
|
◆ Travis()
roboticslab::Travis::Travis |
( |
bool |
quiet = true , |
|
|
bool |
overwrite = true |
|
) |
| |
|
inline |
Travis class constructor.
- Parameters
-
quiet | suppress messages displayed upon success/failure. |
overwrite | will not make a copy (faster, less memory), but will overwrite the image you pass. |
◆ binarize() [1/3]
bool roboticslab::Travis::binarize |
( |
const char * |
algorithm | ) |
|
Binarize the image.
- Parameters
-
algorithm | implemented: "redMinusGreen", "greenMinusRed". |
◆ binarize() [2/3]
bool roboticslab::Travis::binarize |
( |
const char * |
algorithm, |
|
|
const double & |
min, |
|
|
const double & |
max |
|
) |
| |
Binarize the image.
- Parameters
-
algorithm | implemented: "redMinusGreen", "greenMinusRed". |
min | i.e. 110. |
max | i.e. 130. |
◆ binarize() [3/3]
bool roboticslab::Travis::binarize |
( |
const char * |
algorithm, |
|
|
const double & |
threshold |
|
) |
| |
Binarize the image.
- Parameters
-
algorithm | implemented: "redMinusGreen", "greenMinusRed". |
threshold | i.e. 50. |
◆ blobize()
int roboticslab::Travis::blobize |
( |
const int & |
maxNumBlobs | ) |
|
Use findContours to get what we use as blobs.
- Parameters
-
maxNumBlobs | the 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
-
method | 0=box, 1=ellipse. |
angles | returned. |
◆ getBlobsArea()
bool roboticslab::Travis::getBlobsArea |
( |
std::vector< double > & |
areas | ) |
|
This function calculates the Area of the blobs (contours).
- Parameters
-
◆ 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
-
aspectRatios | returned. |
axisFirsts | returned. |
axisSeconds | returned. |
◆ 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
-
hues | returned. |
vals | returned. |
sats | returned. |
hueStdDevs | returned. |
valStdDevs | returned. |
satStdDevs | returned. |
◆ getBlobsRectangularity()
bool roboticslab::Travis::getBlobsRectangularity |
( |
std::vector< double > & |
rectangularities | ) |
|
This function calculates the Rectangularities of the stored _minRotatedRects.
- Parameters
-
rectangularities | returned. |
◆ getBlobsSolidity()
bool roboticslab::Travis::getBlobsSolidity |
( |
std::vector< double > & |
solidities | ) |
|
This function calculates the Solidity of the blobs (contours).
- Parameters
-
◆ 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
-
◆ getCvMat()
cv::Mat & roboticslab::Travis::getCvMat |
( |
const int & |
image, |
|
|
const int & |
vizualization |
|
) |
| |
Get the image in cv::Mat format.
- Parameters
-
image | |
vizualization | param, 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
-
closure | i.e. 4 for a 100x100 image, 15 for higher resolution. |
◆ morphOpening()
void roboticslab::Travis::morphOpening |
( |
const int & |
opening | ) |
|
Morphologically opening the binarized image.
- Parameters
-
opening | i.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
-
contour | to 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
-
image | the 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
-
image | the image to set, in cv::Mat format. |
- Returns
- true if the object was set successfully.
◆ _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 |
◆ _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:
- libraries/TravisLib/TravisLib.hpp
- libraries/TravisLib/TravisLib.cpp