Image Component Library (ICL)
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
icl::cv::HoughLine Struct Reference

Line Equation structure. More...

#include <HoughLine.h>

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

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

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

◆ HoughLine() [1/3]

icl::cv::HoughLine::HoughLine ( )

empty constructor (all line values are set to 0)

◆ HoughLine() [2/3]

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

create a line by given parameters

Parameters
offsoffset vector
dirdirection vector

◆ HoughLine() [3/3]

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

◆ getIntersection()

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.

◆ getPairwiseIntersections()

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

calculates all pairwise intersection within a set of lines

◆ rho()

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

convenence function for transf. into IppPointPolar

◆ sample()

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

draws the line into an image

◆ theta()

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

convenence function for transf. into IppPointPolar

Member Data Documentation

◆ m_angle

float icl::cv::HoughLine::m_angle
private

◆ m_direction

utils::Point32f icl::cv::HoughLine::m_direction
private

◆ m_distance

float icl::cv::HoughLine::m_distance
private

◆ m_offset

utils::Point32f icl::cv::HoughLine::m_offset
private

◆ NO_INTERSECTION

const utils::Point32f icl::cv::HoughLine::NO_INTERSECTION
static

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


The documentation for this struct was generated from the following file: