JeVoisBase  1.0
JeVois Smart Embedded Machine Vision Toolkit Base Modules
RoadFinder Class Reference

Navigation by finding road. More...

#include </lab/itti/jevois/software/jevoisbase/src/Components/RoadFinder/RoadFinder.H>

Inheritance diagram for RoadFinder:
Collaboration diagram for RoadFinder:

Public Member Functions

 RoadFinder (std::string const &instance)
 constructor More...
 
virtual ~RoadFinder ()
 desctructor More...
 
void process (cv::Mat const &img, jevois::RawImage &visual)
 Compute the vanishing point location using the full blown algorithm. More...
 
std::pair< Point2D< int >, float > getCurrVanishingPoint () const
 Get the current vanishing point and confidence. More...
 
Point2D< float > getCurrCenterPoint () const
 Get the current road center point. More...
 
Point2D< float > getCurrTargetPoint () const
 Get the current target point. More...
 
float getFilteredTargetX () const
 Get the kalman-fitered target X, can be used to set robot steering. More...
 
void resetRoadModel ()
 Reset all tracker internals and start fresh (e.g., when changing goal direction) More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< ComponentgetSubComponent (std::string const &instance) const
 
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 &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string 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 &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
void setPath (std::string const &path)
 
std::string absolutePath (std::string 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. More...
 
void preUninit () override
 This class has state and does not support some online param changes. More...
 
void computeHoughSegments (cv::Mat const &cvImage)
 compute the hough segments in the image More...
 
std::vector< LinecomputeVanishingLines (cv::Mat const &edgeMap, Point2D< int > const &vanishingPoint, jevois::RawImage &visual)
 main function to detect the road More...
 
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 More...
 
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 More...
 
Point2D< int > getVanishingPoint (std::vector< Line > const &lines, float &confidence)
 estimate the vanishing point from the tracked lines More...
 
void trackVanishingLines (cv::Mat const &edgeMap, std::vector< Line > &currentLines, jevois::RawImage &visual)
 track vanishing lines by to fit to the new, inputted, edgemap More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
void projectForwardVanishingLines (std::vector< Line > &lines, std::vector< cv::Mat > const &edgeMaps, jevois::RawImage &visual)
 update the lines with the inputted set of edgemaps More...
 
std::vector< Linecombine (std::vector< Line > &prevLines, std::vector< Line > const &currentLines, int width, int height)
 combine two lines sets, discard duplicates and overlaps More...
 
std::vector< LinediscardDuplicates (std::vector< Line > const &currentLines)
 discard duplicate lines in a set More...
 
- 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 More...
 
Point2D< float > itsAccumulatedTrajectory
 the accumulated trajectory More...
 
std::mutex itsAccTrajMtx
 locking accunulated trajectory More...
 
std::vector< SegmentitsCurrentSegments
 current segments found using CVHoughlines More...
 
std::mutex itsTrackMtx
 locking line trackers vars More...
 
bool itsTrackingFlag
 indicate whether tracking More...
 
std::vector< LineitsCurrentLines
 the current lines being tracked More...
 
uint itsNumIdentifiedLines
 indicate how many unique lines have been identified NOTE: never reset More...
 
RoadModel itsRoadModel
 
std::vector< VanishingPointitsVanishingPoints
 vanishing points being considered More...
 
std::mutex itsRoadMtx
 
Point2D< int > itsVanishingPoint
 current vanishing point More...
 
Point2D< float > itsCenterPoint
 current center of road point More...
 
Point2D< float > itsTargetPoint
 target servo point More...
 
float itsVanishingPointConfidence
 current vanishing point More...
 
std::vector< bool > itsVanishingPointStability
 vanishing point score tracker More...
 
int itsCurrentMessageID
 for visualizer More...
 
cv::KalmanFilter itsTPXfilter
 
float itsFilteredTPX
 
bool itsKalmanNeedInit
 

Related Functions

(Note that these are not member functions.)

#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 
#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 
#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 
#define JEVOIS_DECLARE_PARAMETER(ParamName, ParamType, ...)
 Parameter. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

RoadFinder::RoadFinder ( std::string const &  instance)
RoadFinder::~RoadFinder ( )
virtual

desctructor

Definition at line 209 of file RoadFinder.C.

Member Function Documentation

std::vector< Line > RoadFinder::combine ( std::vector< Line > &  prevLines,
std::vector< Line > const &  currentLines,
int  width,
int  height 
)
protected

combine two lines sets, discard duplicates and overlaps

Definition at line 1418 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().

void RoadFinder::computeHoughSegments ( cv::Mat const &  cvImage)
protected

compute the hough segments in the image

Definition at line 786 of file RoadFinder.C.

References Point2D< T >::i, itsCurrentSegments, and Point2D< T >::j.

Referenced by process().

Point2D< float > RoadFinder::computeRoadCenterPoint ( cv::Mat const &  edgeMap,
std::vector< Line > &  lines,
Point2D< int > &  vanishing_point,
Point2D< float > &  road_center_point,
float &  confidence 
)
protected

computes the road center point to servo to

Definition at line 433 of file RoadFinder.C.

References getVanishingPoint(), Point2D< T >::i, itsRoadMtx, itsVanishingPoint, itsVanishingPointStability, and Point2D< T >::j.

Referenced by process().

std::vector< Line > RoadFinder::computeVanishingLines ( cv::Mat const &  edgeMap,
Point2D< int > const &  vanishingPoint,
jevois::RawImage visual 
)
protected
std::vector< Line > RoadFinder::discardDuplicates ( std::vector< Line > const &  currentLines)
protected

discard duplicate lines in a set

Definition at line 1486 of file RoadFinder.C.

References Point2D< T >::distance(), Line::onScreenHorizonSupportPoint, Line::onScreenRoadBottomPoint, and Line::score.

Referenced by combine().

Line RoadFinder::findLine2 ( Segment const &  s,
cv::Mat const &  edgeMap,
std::list< Segment > const &  supportingSegments,
std::vector< bool > &  is_used,
float &  totalLength,
uint numSegments 
)
protected
void RoadFinder::fitLine ( std::vector< Point2D< int > > const &  points,
Point2D< float > &  p1,
Point2D< float > &  p2,
int const  width,
int const  height 
)
protected

openCV wrapper function to fit a line to an input vector of points

Definition at line 1204 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.

float RoadFinder::getLineFitness ( Point2D< int > const &  horizonPoint,
Point2D< int > const &  roadBottomPoint,
cv::Mat const &  edgeMap,
jevois::RawImage visual 
)
protected

compute how well the line equation fit the edgels in edgemap

Definition at line 1230 of file RoadFinder.C.

Referenced by computeVanishingLines(), and trackVanishingLines().

float RoadFinder::getLineFitness ( Point2D< int > const &  horizonPoint,
Point2D< int > const &  roadBottomPoint,
cv::Mat const &  edgeMap,
std::vector< Point2D< int > > &  points,
jevois::RawImage visual 
)
protected

compute how well the line equation fit the edgels in edgemap

Definition at line 1238 of file RoadFinder.C.

References Point2D< T >::distance(), jevois::rawimage::drawDisk(), jevois::rawimage::drawLine(), getPixels(), getPixelsQuick(), Point2D< T >::i, Point2D< T >::j, and jevois::RawImage::valid().

std::vector< Point2D< int > > RoadFinder::getPixels ( Point2D< int > const &  p1,
Point2D< int > const &  p2,
cv::Mat const &  edgeMap 
)
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 954 of file RoadFinder.C.

Referenced by findLine2(), and getLineFitness().

std::vector< Point2D< int > > RoadFinder::getPixels ( Point2D< int > const &  p1,
Point2D< int > const &  p2,
cv::Mat const &  edgeMap,
std::vector< uint > &  startIndexes 
)
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 962 of file RoadFinder.C.

References Point2D< T >::distance(), Point2D< T >::i, and Point2D< T >::j.

std::vector< Point2D< int > > RoadFinder::getPixelsQuick ( Point2D< int > const &  p1,
Point2D< int > const &  p2,
cv::Mat const &  edgeMap 
)
protected

get pixels that make up the segment defined by p1 and p2

Definition at line 1057 of file RoadFinder.C.

References Point2D< T >::i, and Point2D< T >::j.

Referenced by getLineFitness().

Point2D< int > RoadFinder::getVanishingPoint ( std::vector< Line > const &  lines,
float &  confidence 
)
protected

estimate the vanishing point from the tracked lines

Definition at line 757 of file RoadFinder.C.

References Point2D< T >::i.

Referenced by computeRoadCenterPoint().

void RoadFinder::postInit ( )
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.

References freeze().

void RoadFinder::preUninit ( )
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.

References unFreeze().

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::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::Profiler::start(), jevois::Profiler::stop(), trackVanishingLines(), updateRoadModel(), and jevois::RawImage::valid().

void RoadFinder::projectForwardVanishingLines ( std::vector< Line > &  lines,
std::vector< cv::Mat > const &  edgeMaps,
jevois::RawImage visual 
)
protected

update the lines with the inputted set of edgemaps

Definition at line 1410 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.

void RoadFinder::trackVanishingLines ( cv::Mat const &  edgeMap,
std::vector< Line > &  currentLines,
jevois::RawImage visual 
)
protected

track vanishing lines by to fit to the new, inputted, edgemap

Definition at line 1318 of file RoadFinder.C.

References jevois::rawimage::drawDisk(), jevois::rawimage::drawLine(), getLineFitness(), Point2D< T >::i, Point2D< T >::j, updateLine(), and jevois::RawImage::valid().

Referenced by process(), and projectForwardVanishingLines().

void RoadFinder::updateLine ( Line l,
std::vector< Point2D< int > > const &  points,
float  score,
int const  width,
int const  height 
)
protected

update the information in by updating the input points, score and various handy coordinate locations

Definition at line 1151 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().

void RoadFinder::updateRoadModel ( std::vector< Line > &  lines,
int  index 
)
protected

update road model and incoming lines NOTE: also change the line parameters to sync them this avoids drifts

Definition at line 594 of file RoadFinder.C.

References Point2D< T >::distance(), itsNumIdentifiedLines, itsRoadModel, RoadModel::lastActiveIndex, RoadModel::lastSeenHorizonPoint, RoadModel::lastSeenLocation, RoadModel::lines, and RoadModel::numMatches.

Referenced by process().

Friends And Related Function Documentation

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

#define JEVOIS_DECLARE_PARAMETER (   ParamName,
  ParamType,
  ... 
)
related

Parameter.

Member Data Documentation

std::mutex RoadFinder::itsAccTrajMtx
protected

locking accunulated trajectory

Definition at line 288 of file RoadFinder.H.

Point2D<float> RoadFinder::itsAccumulatedTrajectory
protected

the accumulated trajectory

Definition at line 285 of file RoadFinder.H.

Referenced by RoadFinder().

Point2D<float> RoadFinder::itsCenterPoint
protected

current center of road point

Definition at line 311 of file RoadFinder.H.

Referenced by getCurrCenterPoint(), process(), and RoadFinder().

std::vector<Line> RoadFinder::itsCurrentLines
protected

the current lines being tracked

Definition at line 299 of file RoadFinder.H.

Referenced by process().

int RoadFinder::itsCurrentMessageID
protected

for visualizer

Definition at line 317 of file RoadFinder.H.

std::vector<Segment> RoadFinder::itsCurrentSegments
protected

current segments found using CVHoughlines

Definition at line 291 of file RoadFinder.H.

Referenced by computeHoughSegments(), computeVanishingLines(), and process().

float RoadFinder::itsFilteredTPX
protected

Definition at line 320 of file RoadFinder.H.

Referenced by getFilteredTargetX(), and process().

bool RoadFinder::itsKalmanNeedInit
protected

Definition at line 321 of file RoadFinder.H.

Referenced by process().

uint RoadFinder::itsNumIdentifiedLines
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().

double RoadFinder::itsRoadHeading
protected

the current road heading

Definition at line 282 of file RoadFinder.H.

RoadModel RoadFinder::itsRoadModel
protected

Definition at line 304 of file RoadFinder.H.

Referenced by resetRoadModel(), and updateRoadModel().

std::mutex RoadFinder::itsRoadMtx
protected

Definition at line 309 of file RoadFinder.H.

Referenced by computeRoadCenterPoint(), computeVanishingLines(), and resetRoadModel().

Point2D<float> RoadFinder::itsTargetPoint
protected

target servo point

Definition at line 312 of file RoadFinder.H.

Referenced by getCurrTargetPoint(), process(), and RoadFinder().

cv::KalmanFilter RoadFinder::itsTPXfilter
protected

Definition at line 319 of file RoadFinder.H.

Referenced by process(), and RoadFinder().

bool RoadFinder::itsTrackingFlag
protected

indicate whether tracking

Definition at line 296 of file RoadFinder.H.

Referenced by RoadFinder().

std::mutex RoadFinder::itsTrackMtx
protected

locking line trackers vars

Definition at line 293 of file RoadFinder.H.

Point2D<int> RoadFinder::itsVanishingPoint
protected

current vanishing point

Definition at line 310 of file RoadFinder.H.

Referenced by computeRoadCenterPoint(), computeVanishingLines(), getCurrVanishingPoint(), process(), and RoadFinder().

float RoadFinder::itsVanishingPointConfidence
protected

current vanishing point

Definition at line 313 of file RoadFinder.H.

Referenced by getCurrVanishingPoint(), process(), and RoadFinder().

std::vector<VanishingPoint> RoadFinder::itsVanishingPoints
protected

vanishing points being considered

Definition at line 307 of file RoadFinder.H.

Referenced by computeVanishingLines(), and process().

std::vector<bool> RoadFinder::itsVanishingPointStability
protected

vanishing point score tracker

Definition at line 314 of file RoadFinder.H.

Referenced by computeRoadCenterPoint().


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