JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Navigation by finding road. More...
#include <jevoisbase/Components/RoadFinder/RoadFinder.H>
Public Member Functions | |
RoadFinder (std::string const &instance) | |
constructor | |
virtual | ~RoadFinder () |
desctructor | |
void | process (cv::Mat const &img, jevois::RawImage &visual) |
Compute the vanishing point location using the full blown algorithm. | |
std::pair< Point2D< int >, float > | getCurrVanishingPoint () const |
Get the current vanishing point and confidence. | |
Point2D< float > | getCurrCenterPoint () const |
Get the current road center point. | |
Point2D< float > | getCurrTargetPoint () const |
Get the current target point. | |
float | getFilteredTargetX () const |
Get the kalman-fitered target X, can be used to set robot steering. | |
void | resetRoadModel () |
Reset all tracker internals and start fresh (e.g., when changing goal direction) | |
Public Member Functions inherited from jevois::Component | |
Component (std::string const &instance) | |
virtual | ~Component () |
std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
bool | isTopLevel () const |
bool | initialized () const |
std::string const & | className () const |
std::string const & | instanceName () const |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
void | freezeAllParams (bool doit) |
std::string | descriptor () const |
void | setParamsFromFile (std::string const &filename) |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
virtual void | paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="") |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
void | setPath (std::string const &path) |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
std::shared_ptr< Comp > | addSubComponent (std::string const &instance, Args &&...args) |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
bool | isTopLevel () const |
bool | initialized () const |
std::string const & | className () const |
std::string const & | instanceName () const |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
void | freezeAllParams (bool doit) |
std::string | descriptor () const |
void | setParamsFromFile (std::string const &filename) |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
virtual void | paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="") |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
void | setPath (std::string const &path) |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
Public Member Functions inherited from jevois::ParameterRegistry | |
virtual | ~ParameterRegistry () |
Protected Member Functions | |
void | postInit () override |
This class has state and does not support some online param changes. | |
void | preUninit () override |
This class has state and does not support some online param changes. | |
void | computeHoughSegments (cv::Mat const &cvImage) |
compute the hough segments in the image | |
std::vector< Line > | computeVanishingLines (cv::Mat const &edgeMap, Point2D< int > const &vanishingPoint, jevois::RawImage &visual) |
main function to detect the road | |
Point2D< float > | computeRoadCenterPoint (cv::Mat const &edgeMap, std::vector< Line > &lines, Point2D< int > &vanishing_point, Point2D< float > &road_center_point, float &confidence) |
computes the road center point to servo to | |
void | updateRoadModel (std::vector< Line > &lines, int index) |
update road model and incoming lines NOTE: also change the line parameters to sync them this avoids drifts | |
Point2D< int > | getVanishingPoint (std::vector< Line > const &lines, float &confidence) |
estimate the vanishing point from the tracked lines | |
void | trackVanishingLines (cv::Mat const &edgeMap, std::vector< Line > ¤tLines, jevois::RawImage &visual) |
track vanishing lines by to fit to the new, inputted, edgemap | |
std::vector< Point2D< int > > | getPixels (Point2D< int > const &p1, Point2D< int > const &p2, cv::Mat const &edgeMap) |
get pixels for segment defined by p1 and p2 have added complexity to search within 1.5 pixels of the line | |
std::vector< Point2D< int > > | getPixels (Point2D< int > const &p1, Point2D< int > const &p2, cv::Mat const &edgeMap, std::vector< uint > &startIndexes) |
get pixels for segment defined by p1 and p2 have added complexity to search within 1.5 pixels of the line | |
std::vector< Point2D< int > > | getPixelsQuick (Point2D< int > const &p1, Point2D< int > const &p2, cv::Mat const &edgeMap) |
get pixels that make up the segment defined by p1 and p2 | |
Line | findLine2 (Segment const &s, cv::Mat const &edgeMap, std::list< Segment > const &supportingSegments, std::vector< bool > &is_used, float &totalLength, uint &numSegments) |
find lines given the found supporting segments | |
void | fitLine (std::vector< Point2D< int > > const &points, Point2D< float > &p1, Point2D< float > &p2, int const width, int const height) |
openCV wrapper function to fit a line to an input vector of points | |
float | getLineFitness (Point2D< int > const &horizonPoint, Point2D< int > const &roadBottomPoint, cv::Mat const &edgeMap, jevois::RawImage &visual) |
compute how well the line equation fit the edgels in edgemap | |
float | getLineFitness (Point2D< int > const &horizonPoint, Point2D< int > const &roadBottomPoint, cv::Mat const &edgeMap, std::vector< Point2D< int > > &points, jevois::RawImage &visual) |
compute how well the line equation fit the edgels in edgemap | |
void | updateLine (Line &l, std::vector< Point2D< int > > const &points, float score, int const width, int const height) |
update the information in by updating the input points, score and various handy coordinate locations | |
void | projectForwardVanishingLines (std::vector< Line > &lines, std::vector< cv::Mat > const &edgeMaps, jevois::RawImage &visual) |
update the lines with the inputted set of edgemaps | |
std::vector< Line > | combine (std::vector< Line > &prevLines, std::vector< Line > const ¤tLines, int width, int height) |
combine two lines sets, discard duplicates and overlaps | |
std::vector< Line > | discardDuplicates (std::vector< Line > const ¤tLines) |
discard duplicate lines in a set | |
Protected Member Functions inherited from jevois::Component | |
virtual void | preInit () |
virtual void | postUninit () |
virtual void | preInit () |
virtual void | postUninit () |
Protected Member Functions inherited from jevois::ParameterRegistry | |
void | addParameter (ParameterBase *const param) |
void | removeParameter (ParameterBase *const param) |
void | callbackInitCall () |
Protected Attributes | |
double | itsRoadHeading |
the current road heading | |
Point2D< float > | itsAccumulatedTrajectory |
the accumulated trajectory | |
std::mutex | itsAccTrajMtx |
locking accunulated trajectory | |
std::vector< Segment > | itsCurrentSegments |
current segments found using CVHoughlines | |
std::mutex | itsTrackMtx |
locking line trackers vars | |
bool | itsTrackingFlag |
indicate whether tracking | |
std::vector< Line > | itsCurrentLines |
the current lines being tracked | |
uint | itsNumIdentifiedLines |
indicate how many unique lines have been identified NOTE: never reset | |
RoadModel | itsRoadModel |
std::vector< VanishingPoint > | itsVanishingPoints |
vanishing points being considered | |
std::mutex | itsRoadMtx |
Point2D< int > | itsVanishingPoint |
current vanishing point | |
Point2D< float > | itsCenterPoint |
current center of road point | |
Point2D< float > | itsTargetPoint |
target servo point | |
float | itsVanishingPointConfidence |
current vanishing point | |
std::vector< bool > | itsVanishingPointStability |
vanishing point score tracker | |
int | itsCurrentMessageID |
for visualizer | |
cv::KalmanFilter | itsTPXfilter |
float | itsFilteredTPX |
bool | itsKalmanNeedInit |
Related Symbols | |
(Note that these are not member symbols.) | |
JEVOIS_DECLARE_PARAMETER (horizon, int, "Estimated vertical (Y) position of the horizon (pixels, " "with 0 at the top of the frame). Adjust this depending on the tilt angle of your camera " "and video input resolution.", 70, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (support, int, "Offset (in pixels) between horizon line and horizon support line (positive " "values means support line is below horizon line.", 20, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (spacing, unsigned int, "Spacing between vanishing point candidates (pixels).", 20, ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (distthresh, unsigned int, "Vanishing point distance threshold (pixels).", 40, ParamCateg) | |
Parameter. | |
Navigation by finding road.
This algorithm implements the algorithm described in: C.-K. Chang, C. Siagian, L. Itti, Mobile Robot Monocular Vision Navigation Based on Road Region and Boundary Estimation, In: Proc. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 1043-1050, Oct 2012.
See the research paper at http://ilab.usc.edu/publications/doc/Chang_etal12iros.pdf
Definition at line 176 of file RoadFinder.H.
RoadFinder::RoadFinder | ( | std::string const & | instance | ) |
constructor
Definition at line 181 of file RoadFinder.C.
References Point2D< T >::i, itsAccumulatedTrajectory, itsCenterPoint, itsNumIdentifiedLines, itsTargetPoint, itsTPXfilter, itsTrackingFlag, itsVanishingPoint, itsVanishingPointConfidence, and Point2D< T >::j.
|
virtual |
desctructor
Definition at line 209 of file RoadFinder.C.
|
protected |
combine two lines sets, discard duplicates and overlaps
Definition at line 1422 of file RoadFinder.C.
References Line::angleToCenter, discardDuplicates(), Point2D< T >::distance(), Line::index, Line::isActive, Line::offset, Line::pointToServo, Line::scores, Line::start_scores, and updateLine().
Referenced by process().
|
protected |
compute the hough segments in the image
Definition at line 789 of file RoadFinder.C.
References Point2D< T >::i, itsCurrentSegments, and Point2D< T >::j.
Referenced by process().
|
protected |
computes the road center point to servo to
Definition at line 436 of file RoadFinder.C.
References getVanishingPoint(), Point2D< T >::i, itsRoadMtx, itsVanishingPoint, itsVanishingPointStability, and Point2D< T >::j.
Referenced by process().
|
protected |
main function to detect the road
Definition at line 822 of file RoadFinder.C.
References Point2D< T >::distance(), findLine2(), getLineFitness(), Point2D< T >::i, itsCurrentSegments, itsRoadMtx, itsVanishingPoint, itsVanishingPoints, Point2D< T >::j, Segment::length, Line::onScreenHorizonSupportPoint, Line::onScreenRoadBottomPoint, Segment::p1, Segment::p2, Line::score, and Line::start_scores.
Referenced by process().
|
protected |
discard duplicate lines in a set
Definition at line 1490 of file RoadFinder.C.
References Point2D< T >::distance(), Line::onScreenHorizonSupportPoint, Line::onScreenRoadBottomPoint, and Line::score.
Referenced by combine().
|
protected |
find lines given the found supporting segments
Definition at line 1096 of file RoadFinder.C.
References Point2D< T >::distance(), getPixels(), Segment::length, Line::length, Line::onScreenHorizonSupportPoint, Line::onScreenRoadBottomPoint, Segment::p1, Segment::p2, Line::score, Line::segments, and updateLine().
Referenced by computeVanishingLines().
|
protected |
openCV wrapper function to fit a line to an input vector of points
Definition at line 1207 of file RoadFinder.C.
References Point2D< T >::i, and Point2D< T >::j.
Referenced by updateLine().
Point2D< float > RoadFinder::getCurrCenterPoint | ( | ) | const |
Get the current road center point.
Definition at line 233 of file RoadFinder.C.
References itsCenterPoint.
Point2D< float > RoadFinder::getCurrTargetPoint | ( | ) | const |
Get the current target point.
Definition at line 237 of file RoadFinder.C.
References itsTargetPoint.
std::pair< Point2D< int >, float > RoadFinder::getCurrVanishingPoint | ( | ) | const |
Get the current vanishing point and confidence.
Definition at line 229 of file RoadFinder.C.
References itsVanishingPoint, and itsVanishingPointConfidence.
float RoadFinder::getFilteredTargetX | ( | ) | const |
Get the kalman-fitered target X, can be used to set robot steering.
Definition at line 241 of file RoadFinder.C.
References itsFilteredTPX.
|
protected |
compute how well the line equation fit the edgels in edgemap
Definition at line 1233 of file RoadFinder.C.
References getLineFitness().
Referenced by computeVanishingLines(), getLineFitness(), and trackVanishingLines().
|
protected |
compute how well the line equation fit the edgels in edgemap
Definition at line 1241 of file RoadFinder.C.
References Point2D< T >::distance(), jevois::rawimage::drawDisk(), jevois::rawimage::drawLine(), getPixels(), getPixelsQuick(), Point2D< T >::i, Point2D< T >::j, jevois::yuyv::LightTeal, and jevois::RawImage::valid().
|
protected |
get pixels for segment defined by p1 and p2 have added complexity to search within 1.5 pixels of the line
Definition at line 957 of file RoadFinder.C.
References getPixels().
Referenced by findLine2(), getLineFitness(), and getPixels().
|
protected |
get pixels for segment defined by p1 and p2 have added complexity to search within 1.5 pixels of the line
Definition at line 965 of file RoadFinder.C.
References Point2D< T >::distance(), h, Point2D< T >::i, and Point2D< T >::j.
|
protected |
get pixels that make up the segment defined by p1 and p2
Definition at line 1060 of file RoadFinder.C.
References h, Point2D< T >::i, and Point2D< T >::j.
Referenced by getLineFitness().
|
protected |
estimate the vanishing point from the tracked lines
Definition at line 760 of file RoadFinder.C.
References Point2D< T >::i.
Referenced by computeRoadCenterPoint().
|
overrideprotectedvirtual |
This class has state and does not support some online param changes.
Reimplemented from jevois::Component.
Definition at line 213 of file RoadFinder.C.
|
overrideprotectedvirtual |
This class has state and does not support some online param changes.
Reimplemented from jevois::Component.
Definition at line 221 of file RoadFinder.C.
void RoadFinder::process | ( | cv::Mat const & | img, |
jevois::RawImage & | visual | ||
) |
Compute the vanishing point location using the full blown algorithm.
img should be greyscale. If visual is valid, it should be YUYV with same or larger dims, with the assumption that it contains a color copy of the input frame in the top-left corner (this is used for debug visualizations of the various things computed).
FIXME
Definition at line 256 of file RoadFinder.C.
References jevois::Profiler::checkpoint(), combine(), computeHoughSegments(), computeRoadCenterPoint(), computeVanishingLines(), jevois::yuyv::DarkGreen, jevois::yuyv::DarkGrey, jevois::yuyv::DarkPink, jevois::rawimage::drawDisk(), jevois::rawimage::drawLine(), Point2D< T >::i, Point2D< T >::isValid(), itsCenterPoint, itsCurrentLines, itsCurrentSegments, itsFilteredTPX, itsKalmanNeedInit, itsTargetPoint, itsTPXfilter, itsVanishingPoint, itsVanishingPointConfidence, itsVanishingPoints, Point2D< T >::j, JEVOIS_WAIT_GET_FUTURE, jevois::yuyv::LightGreen, jevois::yuyv::LightGrey, jevois::yuyv::LightPink, jevois::yuyv::MedGreen, jevois::Profiler::start(), jevois::Profiler::stop(), trackVanishingLines(), updateRoadModel(), jevois::RawImage::valid(), and jevois::yuyv::White.
|
protected |
update the lines with the inputted set of edgemaps
Definition at line 1414 of file RoadFinder.C.
References trackVanishingLines().
void RoadFinder::resetRoadModel | ( | ) |
Reset all tracker internals and start fresh (e.g., when changing goal direction)
Thread-safe, ok to call concurrently with process().
Definition at line 245 of file RoadFinder.C.
References itsRoadModel, itsRoadMtx, RoadModel::lastActiveIndex, RoadModel::lastSeenHorizonPoint, RoadModel::lastSeenLocation, RoadModel::lines, and RoadModel::numMatches.
|
protected |
track vanishing lines by to fit to the new, inputted, edgemap
Definition at line 1321 of file RoadFinder.C.
References jevois::rawimage::drawDisk(), jevois::rawimage::drawLine(), getLineFitness(), Point2D< T >::i, Point2D< T >::j, jevois::yuyv::MedPurple, updateLine(), and jevois::RawImage::valid().
Referenced by process(), and projectForwardVanishingLines().
|
protected |
update the information in by updating the input points, score and various handy coordinate locations
Definition at line 1154 of file RoadFinder.C.
References Line::angle, fitLine(), Line::horizonPoint, Line::horizonSupportPoint, Point2D< T >::i, Point2D< T >::j, Line::onScreenHorizonPoint, Line::onScreenHorizonSupportPoint, Line::onScreenRoadBottomPoint, Line::points, Line::roadBottomPoint, and Line::score.
Referenced by combine(), findLine2(), and trackVanishingLines().
|
protected |
update road model and incoming lines NOTE: also change the line parameters to sync them this avoids drifts
Definition at line 597 of file RoadFinder.C.
References Point2D< T >::distance(), itsNumIdentifiedLines, itsRoadModel, RoadModel::lastActiveIndex, RoadModel::lastSeenHorizonPoint, RoadModel::lastSeenLocation, RoadModel::lines, and RoadModel::numMatches.
Referenced by process().
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
protected |
locking accunulated trajectory
Definition at line 288 of file RoadFinder.H.
|
protected |
|
protected |
current center of road point
Definition at line 311 of file RoadFinder.H.
Referenced by getCurrCenterPoint(), process(), and RoadFinder().
|
protected |
the current lines being tracked
Definition at line 299 of file RoadFinder.H.
Referenced by process().
|
protected |
for visualizer
Definition at line 317 of file RoadFinder.H.
|
protected |
current segments found using CVHoughlines
Definition at line 291 of file RoadFinder.H.
Referenced by computeHoughSegments(), computeVanishingLines(), and process().
|
protected |
Definition at line 320 of file RoadFinder.H.
Referenced by getFilteredTargetX(), and process().
|
protected |
Definition at line 321 of file RoadFinder.H.
Referenced by process().
|
protected |
indicate how many unique lines have been identified NOTE: never reset
Definition at line 302 of file RoadFinder.H.
Referenced by RoadFinder(), and updateRoadModel().
|
protected |
the current road heading
Definition at line 282 of file RoadFinder.H.
|
protected |
Definition at line 304 of file RoadFinder.H.
Referenced by resetRoadModel(), and updateRoadModel().
|
protected |
Definition at line 309 of file RoadFinder.H.
Referenced by computeRoadCenterPoint(), computeVanishingLines(), and resetRoadModel().
|
protected |
target servo point
Definition at line 312 of file RoadFinder.H.
Referenced by getCurrTargetPoint(), process(), and RoadFinder().
|
protected |
Definition at line 319 of file RoadFinder.H.
Referenced by process(), and RoadFinder().
|
protected |
|
protected |
locking line trackers vars
Definition at line 293 of file RoadFinder.H.
|
protected |
current vanishing point
Definition at line 310 of file RoadFinder.H.
Referenced by computeRoadCenterPoint(), computeVanishingLines(), getCurrVanishingPoint(), process(), and RoadFinder().
|
protected |
current vanishing point
Definition at line 313 of file RoadFinder.H.
Referenced by getCurrVanishingPoint(), process(), and RoadFinder().
|
protected |
vanishing points being considered
Definition at line 307 of file RoadFinder.H.
Referenced by computeVanishingLines(), and process().
|
protected |
vanishing point score tracker
Definition at line 314 of file RoadFinder.H.
Referenced by computeRoadCenterPoint().