Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
icl::cv::HoughLine Struct Reference

Line Equation structure. More...

#include <HoughLine.h>

List of all members.

Public Member Functions

 HoughLine ()
 empty constructor (all line values are set to 0)
 HoughLine (const utils::Point32f &offs, const utils::Point32f &dir)
 create a line by given parameters
 HoughLine (icl32f distance, icl32f angle)
 create a line by given distance and angle
void sample (core::ImgBase *image, icl32f r, icl32f g, icl32f b, icl32f alpha=255) const
 draws the line into an image
float rho () const
 convenence function for transf. into IppPointPolar
float theta () const
 convenence function for transf. into IppPointPolar

Static Public Member Functions

static utils::Point32f getIntersection (const HoughLine &a, const HoughLine &b)
 Computes the intersection between two lines.
static std::vector
< utils::Point32f
getPairwiseIntersections (const std::vector< HoughLine > &lines)
 calculates all pairwise intersection within a set of lines

Static Public Attributes

static const utils::Point32f NO_INTERSECTION
 indicator for no found intersection (lines intersect in infinity -- max-float)

Private Attributes

float m_distance
float m_angle
utils::Point32f m_offset
utils::Point32f m_direction

Detailed Description

Line Equation structure.

Lines can (among others) be represented in parameter form:

\[ l: \vec{o}+\lambda \vec{d} \]

,or by given radius $r$ and angle $\alpha $.

\[ x \cos(\alpha) + y \sin(\alpha) - r = 0 \]

This class provides both information.


Constructor & Destructor Documentation

empty constructor (all line values are set to 0)

icl::cv::HoughLine::HoughLine ( const utils::Point32f offs,
const utils::Point32f dir 
)

create a line by given parameters

Parameters:
offsoffset vector
dirdirection vector
icl::cv::HoughLine::HoughLine ( icl32f  distance,
icl32f  angle 
)

create a line by given distance and angle

Parameters:
distancedistance from the origin
angleangle of vector perpendicular to the line

Member Function Documentation

static utils::Point32f icl::cv::HoughLine::getIntersection ( const HoughLine a,
const HoughLine b 
) [static]

Computes the intersection between two lines.

Assuming two lines given in polar coordinates

\[ x \cos(\alpha) + y \sin(\alpha) - r = 0 \]

,

which can be seen geometrically, as a line that is perpendicular to the vector $ (\cos(\alpha), \sin(\alpha) )^{\tau} $ with distance r to the origin, we can calculate the intersection as follows:

Firstly, we have to transform the line equations into parameter form

\[ l: \vec{o}+\lambda \vec{d} \]

(offset- and direction vector) using the following rules

\[ \vec{o} = r * ( \cos(\alpha) \sin(\alpha) )^{\tau} \]

\[ \vec{d} = ( -\sin(\alpha) \cos(\alpha) ]^{\tau} \]

This results in:

\[ g_1: \vec{o}_1+ \lambda_1 * \vec{d}_1 \]

(using angle $\alpha$ and distance $r$) and

\[ g_2: \vec{o}_2+ \lambda_2 * \vec{d}_2 \]

(using angle $\beta$ and distance $s$) and

The intersection can be calculated by solving the equation system

\[ g1 = g2 \]

, or in other words:

\[ \lambda_1\cdot -\sin(\alpha) + \lambda_2 \cdot \sin(\beta) = s\cos(\beta) - r\cos(\alpha) \]

\[ \lambda_1\cdot \cos(\alpha) + \lambda_2 \cdot -\cos(\beta) = s\sin(\beta) - r\sin(\alpha) \]

This is equal to

\[ Mx = b \]

With

\[ M = \left( \begin{array}{cc} -\sin(\alpha) & \sin(\beta) \\ \cos(\alpha) & -\cos(\beta) \\ \end{array} \right) \]

\[ B = \left( \begin{array}{c} s\cos(\beta) - r\cos(\alpha) \\ s\sin(\beta) - r\sin(\alpha) \\ \end{array} \right) \]

and

\[ x = (\lambda_1, \lambda_2)^{\tau} \]

Of course $ Mx=b $ can be solved by $x=M^{-1}b$

If the lines do not intersect ( $\alpha$ and $\beta$ are very similar), $M$ becomes singular and it's inverse cannot be calculated. This function returns NO_INTERSECTION in this case.

static std::vector<utils::Point32f> icl::cv::HoughLine::getPairwiseIntersections ( const std::vector< HoughLine > &  lines) [static]

calculates all pairwise intersection within a set of lines

float icl::cv::HoughLine::rho ( ) const [inline]

convenence function for transf. into IppPointPolar

void icl::cv::HoughLine::sample ( core::ImgBase image,
icl32f  r,
icl32f  g,
icl32f  b,
icl32f  alpha = 255 
) const

draws the line into an image

float icl::cv::HoughLine::theta ( ) const [inline]

convenence function for transf. into IppPointPolar


Member Data Documentation

float icl::cv::HoughLine::m_angle [private]

indicator for no found intersection (lines intersect in infinity -- max-float)


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines