VLTIF
CS426FinalProject
Lane Class Reference

Structure which stores relevant lane polygon information. More...

#include <Lane.h>

List of all members.

Public Member Functions

 Lane ()
bool isInside (Point pt) const
void draw (Mat &img) const
void addVertex (Point pt)
void changeLast (Point pt)
size_t vertex_count () const
const vector< Point > & getVertices () const
bool finalize ()
void clear ()
size_t size ()
void pop ()
Rect bbox () const

Public Attributes

Drawing Parameters
Scalar color
int thickness
int lineType
int shift

Private Attributes

vector< Point > vertices
model::polygon
< model::d2::point_xy< int > > 
poly
Rect m_bbox

Detailed Description

Structure which stores relevant lane polygon information.

Definition at line 35 of file Lane.h.


Constructor & Destructor Documentation

Lane::Lane ( )

Default lane constructor

Definition at line 13 of file Lane.cpp.

           :
   color(CV_RGB(50,255,50)),
   thickness(2),
   lineType(8),
   shift(0)
{}

Member Function Documentation

void Lane::addVertex ( Point  pt)

Add vertex to list

Parameters:
ptnew point

Definition at line 41 of file Lane.cpp.

References vertices.

Referenced by draw_lanes(), and load_lanes().

{
   vertices.push_back(pt);
}
Rect Lane::bbox ( ) const

Return the bounding box of the lane

Returns:
lane best fit rectangle

Definition at line 162 of file Lane.cpp.

References m_bbox.

                    {
    return m_bbox;
}
void Lane::changeLast ( Point  pt)

Adjust the last point

Parameters:
pt

Definition at line 50 of file Lane.cpp.

References vertices.

Referenced by draw_lanes().

{
   vertices.back() = pt;
}
void Lane::clear ( )

Clear the list of vertices

Definition at line 140 of file Lane.cpp.

References vertices.

Referenced by draw_lanes(), and load_lanes().

                {
    vertices.clear();
}
void Lane::draw ( Mat &  img) const

Draw the lane onto the image

Parameters:
imgimage to draw

Definition at line 117 of file Lane.cpp.

References color, lineType, shift, size(), thickness, and vertices.

Referenced by draw_lanes().

{
   const int size = static_cast<int>(vertices.size());

   //create a pointer to point to
   const Point* pts_ptr = &(vertices[0]);

   polylines(
      img,
      &pts_ptr,
      &size,
      1,
      true,
      color,
      thickness,
      lineType,
      shift
   );
}
bool Lane::finalize ( )

Call when finished modifying

Convert the vertex list into a boost polygon

Returns:
true if successful

Definition at line 77 of file Lane.cpp.

References m_bbox, poly, and vertices.

{
   if ( vertices.size() < 3 ) return false;
   
   using boost::assign::tuple_list_of;
   using boost::make_tuple;
   using boost::geometry::append;
   
   Point minP = vertices[0], maxP = vertices[0];
   for( size_t i=1; i<vertices.size(); i++){
       if( vertices[i].x < minP.x ) minP.x = vertices[i].x;
       if( vertices[i].y < minP.y ) minP.y = vertices[i].y;
       if( vertices[i].x > maxP.x ) maxP.x = vertices[i].x;
       if( vertices[i].y > maxP.y ) maxP.y = vertices[i].y;
   }
   m_bbox = Rect(minP.x, minP.y, maxP.x-minP.x, maxP.y-minP.y);
   
   //int* points = &(vertices[0]);
   for ( vector<Point>::iterator i = vertices.begin(); i != vertices.end(); ++i )
      append(poly, tuple_list_of(i->x,i->y));
   append(poly, tuple_list_of(vertices[0].x,vertices[0].y));
   
   return true;
}
const vector< Point > & Lane::getVertices ( ) const

Get the number of vertices

Returns:
vertex list

Definition at line 68 of file Lane.cpp.

References vertices.

{
   return vertices;
}
bool Lane::isInside ( Point  pt) const

Check if point is inside lane

Parameters:
ptpoint to test
Returns:
true if the point is inside the polygon

Definition at line 107 of file Lane.cpp.

References poly.

{
   boost::tuple<int,int> p = boost::make_tuple(pt.x,pt.y);
   return within(p,poly);
}
void Lane::pop ( )

Pop the last vertex

Definition at line 154 of file Lane.cpp.

References vertices.

              {
    vertices.pop_back();
}
size_t Lane::size ( )

Return the size of the vertex list

Definition at line 147 of file Lane.cpp.

References vertices.

Referenced by draw(), and draw_lanes().

                 {
    return vertices.size();
}
size_t Lane::vertex_count ( ) const

Return the number of vertices

Returns:
size of vertex list

Definition at line 59 of file Lane.cpp.

References vertices.

{
   return vertices.size();
}

Member Data Documentation

Scalar Lane::color

Use CV_RGB(r,g,b) macro where r,g,b are [0,255] for uchar images and [0.0, 1.0] for floating point images

Definition at line 61 of file Lane.h.

Referenced by draw().

8 or 4 for 4-connected or 8-connected Bresenham algorithm or CV_AA for anti-aliased lines using Gaussian filtering

Definition at line 64 of file Lane.h.

Referenced by draw().

Rect Lane::m_bbox [private]

Definition at line 75 of file Lane.h.

Referenced by bbox(), and finalize().

model::polygon<model::d2::point_xy<int> > Lane::poly [private]

Definition at line 74 of file Lane.h.

Referenced by finalize(), and isInside().

Number of fractional bits to shift in the point coordinates (probably want to leave 0)

Definition at line 66 of file Lane.h.

Referenced by draw().

In pixels

Definition at line 63 of file Lane.h.

Referenced by draw().

vector<Point> Lane::vertices [private]

Definition at line 73 of file Lane.h.

Referenced by addVertex(), changeLast(), clear(), draw(), finalize(), getVertices(), pop(), size(), and vertex_count().


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