Image Component Library (ICL)
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
icl::markers::BCHCoder Class Reference

Main class for BCH encoding/decoding. More...

#include <BCHCode.h>

Inheritance diagram for icl::markers::BCHCoder:
icl::utils::Uncopyable

Public Member Functions

 BCHCoder ()
 Default constructor. More...
 
 ~BCHCoder ()
 Destructor. More...
 
DecodedBCHCode decode (const BCHCode &code)
 
DecodedBCHCode decode (const icl8u data[36])
 decodes given (correctly oriented) byte image patch More...
 
DecodedBCHCode decode (const core::Img8u &image, bool useROI=true)
 decodes given (correctly oriented) core::Img8u (optionally using its ROI or not) More...
 
DecodedBCHCode2D decode2D (const core::Img8u &image, int maxID=4095, bool useROI=true)
 decodes given core::Img8u (optionally using its ROI or not) More...
 

Static Public Member Functions

static BCHCode encode (int idx)
 encodes a given index in range [0,4095] to a BCHBinary code More...
 
static core::Img8u createMarkerImage (int idx, int border=2, const utils::Size &resultSize=utils::Size::null)
 creates an image that show a given bch marker More...
 
static BCHCode rotateCode (const BCHCode &in)
 interpretes the given 36Bit as 6x6 image and rotates it by clock wise by 90 degree More...
 

Private Attributes

Impl * impl
 internal implementation structure More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

Main class for BCH encoding/decoding.

Due to some internal buffers, this must be implemented as a class

Constructor & Destructor Documentation

◆ BCHCoder()

icl::markers::BCHCoder::BCHCoder ( )

Default constructor.

◆ ~BCHCoder()

icl::markers::BCHCoder::~BCHCoder ( )

Destructor.

Member Function Documentation

◆ createMarkerImage()

static core::Img8u icl::markers::BCHCoder::createMarkerImage ( int  idx,
int  border = 2,
const utils::Size resultSize = utils::Size::null 
)
static

creates an image that show a given bch marker

Parameters
idxwhich marker
borderamount of border pixels (here, we use the unit of marker pixels, the maker code is always 6x6 marker pixels)
resultSizefirst a (2*border+6)x(2*border+6) image of the marker is created. Then it is upscaled to the given utils::Size using nearest neighbour interpolation. If resultSize is null, the (2*border+6)x(2*border+6) image is returned directly without upscaling

◆ decode() [1/3]

DecodedBCHCode icl::markers::BCHCoder::decode ( const BCHCode code)

We use an error correcting 36Bit BCH code that carries 12 bit of information (i.e. each possible code is associated with a unique index (0 <= index <= 4095). The code provides automatic error correction for inputs that have not more than 4 errors. Its minimal hammin distance is 8. The higher the code indices, the lower their hamming distance:

  • min hamming distance > 8 : all
  • min hamming distance > 9 : IDs 0-63
  • min hamming distance > 10 : IDs 0-15
  • min hamming distance > 13 : IDs 0-3
  • min hamming distance > 16 : IDs 0-1

Benchmarks:

Decoding works quite fast, however the decoder works slightly slower if errors have to be corrected. We benchmarked the BCHDecoder on an Intel(R) Xeon(R) CPU E5530 running at 2.40GHz, on 32Bit Ubuntu Linux. Decoding without errors (2ns) Decoding with 1,2 and 3 errors (3ns) Decoding with 4 errors (4ns)

Implementing the Configurable Interface

We used the code implemented by Robert Morelos-Zaragoza. You can find his copyright note in the corresponding .cpp file

◆ decode() [2/3]

DecodedBCHCode icl::markers::BCHCoder::decode ( const icl8u  data[36])

decodes given (correctly oriented) byte image patch

◆ decode() [3/3]

DecodedBCHCode icl::markers::BCHCoder::decode ( const core::Img8u image,
bool  useROI = true 
)

decodes given (correctly oriented) core::Img8u (optionally using its ROI or not)

◆ decode2D()

DecodedBCHCode2D icl::markers::BCHCoder::decode2D ( const core::Img8u image,
int  maxID = 4095,
bool  useROI = true 
)

decodes given core::Img8u (optionally using its ROI or not)

Internally, this methods checks for all 4 possible image rotations and returns the most plausible result.

Rotated Hamming Distances

If we allow rotations, the expected inter-marker hamming distances gets smaller.

  • min hamming distance > 1: all
  • min hamming distance > 2: 3080
  • min hamming distance > 4: 2492
  • min hamming distance > 5: 482
  • min hamming distance > 8: 18
  • min hamming distance > 10: 10
  • min hamming distance > 11: 4

please note that it's best to use the first N IDs if you want to use N markers

◆ encode()

static BCHCode icl::markers::BCHCoder::encode ( int  idx)
static

encodes a given index in range [0,4095] to a BCHBinary code

◆ rotateCode()

static BCHCode icl::markers::BCHCoder::rotateCode ( const BCHCode in)
static

interpretes the given 36Bit as 6x6 image and rotates it by clock wise by 90 degree

Member Data Documentation

◆ impl

Impl* icl::markers::BCHCoder::impl
private

internal implementation structure

implementation pointer


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