Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::CheckerboardDetectorCrossFilter Class Reference

Detects a checkerboard pattern (typically 7x4 inner corners, asymmetric layout recommended) in an image using a cross shaped image filter. More...

#include <FeatureDetector/CheckerboardDetectorCrossFilter.hh>

+ Collaboration diagram for BIAS::CheckerboardDetectorCrossFilter:

Public Member Functions

 CheckerboardDetectorCrossFilter ()
 Standard constructor. More...
 
std::vector< HomgPoint2DGetCheckerboard (Image< unsigned char > img, int numberOfCols=7, int numberOfRows=4, bool upperLeftIsBlack=true)
 Find a checkerboard of size numberOfCols x numberOfRows in the given image. More...
 
virtual ~CheckerboardDetectorCrossFilter ()
 

Static Public Member Functions

static int Compute (BIAS::Image< unsigned char > &img, const unsigned int &xCorners, const unsigned int &yCorners, t_CoordVecf &coords, const bool &saveDebugImage=false)
 Detects a (recommended asymmetric) checkerboard pattern. More...
 

Protected Member Functions

bool doLinesIntersect (HomgPoint2D &a, HomgPoint2D &b, HomgPoint2D &c, HomgPoint2D &d)
 Check if the finite lines a - b and c - d intersect. More...
 
void ExtendTopology (Image< unsigned char > &img, std::vector< HomgPoint2D > &knotPositions, std::deque< std::deque< int > > &rectTopolog)
 Find the side of the rectangular topology which is most likely not on the edge of the checkerboard and extend the checkerboard to it. More...
 
void GenerateRectangularTopology (Image< unsigned char > &img, std::vector< HomgPoint2D > &knotPositions, std::vector< std::vector< int > > &adjacence, std::deque< std::deque< int > > &rectTopolog)
 Generate a rectangular topology out of the adjcence lists. More...
 
double getAverage (Image< unsigned char > &img, HomgPoint2D center, int halfWinSize)
 Get the average image grey value (also for color images) in a window. More...
 
void GetAvgBlackWhiteValue (Image< unsigned char > &img, std::vector< HomgPoint2D > points, double &avgBlack, double &avgWhite, int angleSteps)
 Calculate the average black and white values of the cross filter at a given set of points. More...
 
void GetCCACenter (const std::vector< HomgPoint2D > pixels, std::vector< HomgPoint2D > &centers, int width, int height)
 Calculate a connected components analysis for a given set of pixel coordinates. More...
 
double GetCheckerLineFactor (Image< unsigned char > img, HomgPoint2D a, HomgPoint2D b)
 Calculate a fitness value for the line between a and b to be a checkerboard line. More...
 
void GetFilterResponseSum (Image< unsigned char > &img, std::vector< HomgPoint2D > &response, float threshold=25000.0, int halfWinSize=20, bool fastMode=true)
 Calculate the filter result for the whole image and return the pixel coordinates above the given threshold. More...
 
std::vector< HomgPoint2DGetFinalCheckerboard (Image< unsigned char > &img, std::vector< HomgPoint2D > &knotPositions, std::deque< std::deque< int > > &rectTopolog, int numberOfRows, int numberOfCols, bool upperLeftIsBlack)
 Analyse the rectangular topology and rotate and flip the checkerboard to its unique representation. More...
 
HomgPoint2D lineIntersection (HomgPoint2D &a, HomgPoint2D &b, HomgPoint2D &c, HomgPoint2D &d)
 Calculate the intersection point of the infinite lines a - b and c - d. More...
 
void SearchForMissingTopologyEntries (Image< unsigned char > &img, std::vector< HomgPoint2D > &knotPositions, std::deque< std::deque< int > > &rectTopolog)
 Fill the topology entries that are unknown (negative indices) by generating an appropriate knot. More...
 
void StretchImageValues (Image< unsigned char > &img, unsigned int from, unsigned int to)
 Stretch the image values such that from => 0 and to => 255. More...
 

Protected Attributes

int defaultAngleSteps_
 The default number of rotation stpes performed at each filter evaluation. More...
 
int defaultHalfWinSize_
 The default half window size of the filter window. More...
 
int initialFilterThreshold_
 The initial value for the filter response threshold for a pixel to be evaluated further. More...
 
int initialLineThreshold_
 The initial value for the line threshold in the topology generation. More...
 

Static Protected Attributes

static
CheckerboardDetectorCrossFilter
instancePointer_ = NULL
 Instance pointer if an instance was created. More...
 

Detailed Description

Detects a checkerboard pattern (typically 7x4 inner corners, asymmetric layout recommended) in an image using a cross shaped image filter.

Note
This checker board detecter uses a rotating cross filter that sums up the absolute differences between the two lines of that cross along with a symmetry penalty term. In addition, a line fitness based on differences of the line vicinity and homogeneity is used together with a lot of heuristics.
Author
Andreas Jordt
Date
2010

Definition at line 36 of file CheckerboardDetectorCrossFilter.hh.

Constructor & Destructor Documentation

CheckerboardDetectorCrossFilter::CheckerboardDetectorCrossFilter ( )

Standard constructor.

Definition at line 19 of file CheckerboardDetectorCrossFilter.cpp.

CheckerboardDetectorCrossFilter::~CheckerboardDetectorCrossFilter ( )
virtual

Definition at line 40 of file CheckerboardDetectorCrossFilter.cpp.

Member Function Documentation

int CheckerboardDetectorCrossFilter::Compute ( BIAS::Image< unsigned char > &  img,
const unsigned int &  xCorners,
const unsigned int &  yCorners,
t_CoordVecf coords,
const bool &  saveDebugImage = false 
)
static

Detects a (recommended asymmetric) checkerboard pattern.

Parameters
imgInput image
xCornersNumber of inner checkerboard corners in x direction
yCornersNumber of inner checkerboard corners in y direction
coordsThe resulting set of corner coordinates
saveDebugImageignored (just for compatibility)
Returns
0 for success, <0 for error (e.g. could not detect all inner corners).

Definition at line 47 of file CheckerboardDetectorCrossFilter.cpp.

Referenced by BIAS::ImageCanvasCheckerboardExtract::SelectCheckerboardCorners().

bool CheckerboardDetectorCrossFilter::doLinesIntersect ( HomgPoint2D a,
HomgPoint2D b,
HomgPoint2D c,
HomgPoint2D d 
)
protected

Check if the finite lines a - b and c - d intersect.

Definition at line 1159 of file CheckerboardDetectorCrossFilter.cpp.

void CheckerboardDetectorCrossFilter::ExtendTopology ( Image< unsigned char > &  img,
std::vector< HomgPoint2D > &  knotPositions,
std::deque< std::deque< int > > &  rectTopolog 
)
protected

Find the side of the rectangular topology which is most likely not on the edge of the checkerboard and extend the checkerboard to it.

Parameters
imgInput image
knotPositionsThe image coordinates of the knots
rectTopologThe rectangular topology of the knots

Definition at line 643 of file CheckerboardDetectorCrossFilter.cpp.

void CheckerboardDetectorCrossFilter::GenerateRectangularTopology ( Image< unsigned char > &  img,
std::vector< HomgPoint2D > &  knotPositions,
std::vector< std::vector< int > > &  adjacence,
std::deque< std::deque< int > > &  rectTopolog 
)
protected

Generate a rectangular topology out of the adjcence lists.

Parameters
imgInput image
knotPositionsThe image coordinates of the knots
adjacenceThe adjacence list for each knot
rectTopologThe resulting rectangular output structure

Definition at line 276 of file CheckerboardDetectorCrossFilter.cpp.

double CheckerboardDetectorCrossFilter::getAverage ( BIAS::Image< unsigned char > &  img,
BIAS::HomgPoint2D  center,
int  halfWinSize 
)
protected

Get the average image grey value (also for color images) in a window.

Parameters
imgInput image
centerThe center of the square window
halfWinSizeThe half size of the square the value is calculated from

Definition at line 1176 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

void CheckerboardDetectorCrossFilter::GetAvgBlackWhiteValue ( Image< unsigned char > &  img,
std::vector< HomgPoint2D points,
double &  avgBlack,
double &  avgWhite,
int  angleSteps 
)
protected

Calculate the average black and white values of the cross filter at a given set of points.

Parameters
imgInput image
pointsThe set of positions the filters are evaluated
avgBlackThe resulting average black value
avgWhiteThe resulting average white value
angleStepThe number of rotations of the cross filter

Definition at line 78 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetChannelCount(), and BIAS::Image< StorageType >::GetImageDataArray().

void CheckerboardDetectorCrossFilter::GetCCACenter ( const std::vector< HomgPoint2D pixels,
std::vector< HomgPoint2D > &  centers,
int  width,
int  height 
)
protected

Calculate a connected components analysis for a given set of pixel coordinates.

Parameters
pixelsThe input pixel coordinates
centersThe centers of weight of the resulting cluster
widthThe maximum x component of the input pixels
heightThe maximum y component of the input pixels

Definition at line 239 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::BlobDetectorCCA< StorageType >::Detect(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::SetZero().

vector< HomgPoint2D > CheckerboardDetectorCrossFilter::GetCheckerboard ( Image< unsigned char >  img,
int  numberOfCols = 7,
int  numberOfRows = 4,
bool  upperLeftIsBlack = true 
)

Find a checkerboard of size numberOfCols x numberOfRows in the given image.

Parameters
imgInput image
numberOfColsThe number of corners on the checkerboard in horizontal direction
numberOfRowsThe number of corners on the checkerboard in vertical direction
upperLeftIsBlackSet true if the field between corners (0,0), (0,1), (1,0) and (1,1) is black

Definition at line 946 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

double CheckerboardDetectorCrossFilter::GetCheckerLineFactor ( Image< unsigned char >  img,
HomgPoint2D  a,
HomgPoint2D  b 
)
protected

Calculate a fitness value for the line between a and b to be a checkerboard line.

Definition at line 1196 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

void CheckerboardDetectorCrossFilter::GetFilterResponseSum ( Image< unsigned char > &  img,
std::vector< HomgPoint2D > &  response,
float  threshold = 25000.0,
int  halfWinSize = 20,
bool  fastMode = true 
)
protected

Calculate the filter result for the whole image and return the pixel coordinates above the given threshold.

Parameters
imgInput image
responseThe set of pixels above the threshold
thresholdFilter threshold
halfWinSizeThe size of the cross filter
fastModespeed up the filter search but risk missing some points

Definition at line 133 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

vector< HomgPoint2D > CheckerboardDetectorCrossFilter::GetFinalCheckerboard ( Image< unsigned char > &  img,
std::vector< HomgPoint2D > &  knotPositions,
std::deque< std::deque< int > > &  rectTopolog,
int  numberOfRows,
int  numberOfCols,
bool  upperLeftIsBlack 
)
protected

Analyse the rectangular topology and rotate and flip the checkerboard to its unique representation.

Parameters
imgInput image
knotPositionsThe image coordinates of the knots
rectTopologThe rectangular topology
numberOfRowsThe expected number of rows of the checkerboard
numberOfColsThe expected number of columns of the checkerboard
upperLeftIsBlackSet true if the field between corners (0,0), (0,1), (1,0) and (1,1) is black

Definition at line 844 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::Vector3< T >::CrossProduct(), BIAS::ImageBase::GetChannelCount(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::Vector3< T >::size().

HomgPoint2D CheckerboardDetectorCrossFilter::lineIntersection ( HomgPoint2D a,
HomgPoint2D b,
HomgPoint2D c,
HomgPoint2D d 
)
protected

Calculate the intersection point of the infinite lines a - b and c - d.

Definition at line 1169 of file CheckerboardDetectorCrossFilter.cpp.

void CheckerboardDetectorCrossFilter::SearchForMissingTopologyEntries ( Image< unsigned char > &  img,
std::vector< HomgPoint2D > &  knotPositions,
std::deque< std::deque< int > > &  rectTopolog 
)
protected

Fill the topology entries that are unknown (negative indices) by generating an appropriate knot.

Parameters
imgInput image
knotPositionsThe image coordinates of the knots
rectTopologThe rectangular topology

Definition at line 602 of file CheckerboardDetectorCrossFilter.cpp.

void CheckerboardDetectorCrossFilter::StretchImageValues ( Image< unsigned char > &  img,
unsigned int  from,
unsigned int  to 
)
protected

Stretch the image values such that from => 0 and to => 255.

Parameters
imgInput image
fromThe value that is pulled to 0
toThe value that is pushed to 255

Definition at line 220 of file CheckerboardDetectorCrossFilter.cpp.

References BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), and BIAS::ImageBase::GetWidth().

Member Data Documentation

int BIAS::CheckerboardDetectorCrossFilter::defaultAngleSteps_
protected

The default number of rotation stpes performed at each filter evaluation.

Definition at line 186 of file CheckerboardDetectorCrossFilter.hh.

int BIAS::CheckerboardDetectorCrossFilter::defaultHalfWinSize_
protected

The default half window size of the filter window.

Definition at line 183 of file CheckerboardDetectorCrossFilter.hh.

int BIAS::CheckerboardDetectorCrossFilter::initialFilterThreshold_
protected

The initial value for the filter response threshold for a pixel to be evaluated further.

Definition at line 189 of file CheckerboardDetectorCrossFilter.hh.

int BIAS::CheckerboardDetectorCrossFilter::initialLineThreshold_
protected

The initial value for the line threshold in the topology generation.

Definition at line 192 of file CheckerboardDetectorCrossFilter.hh.

CheckerboardDetectorCrossFilter * CheckerboardDetectorCrossFilter::instancePointer_ = NULL
staticprotected

Instance pointer if an instance was created.

This hack is needed to stay compatible to the static function calls of the other checkerboard detectors

Definition at line 196 of file CheckerboardDetectorCrossFilter.hh.


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