tesseract  4.0.0-1-g2a2b
QRSequenceGenerator Class Reference

#include <qrsequence.h>

Public Member Functions

 QRSequenceGenerator (int N)
 
int GetVal ()
 

Protected Member Functions

int GetBinaryReversedInteger (int in_val) const
 

Protected Attributes

int N_
 
int next_num_
 
int num_bits_
 

Detailed Description

Definition at line 32 of file qrsequence.h.

Constructor & Destructor Documentation

◆ QRSequenceGenerator()

QRSequenceGenerator::QRSequenceGenerator ( int  N)
inlineexplicit

Definition at line 35 of file qrsequence.h.

35  : N_(N), next_num_(0) {
36  num_bits_ = static_cast<int>(ceil(log(static_cast<double>(N)) / log(2.0)));
37  }

Member Function Documentation

◆ GetBinaryReversedInteger()

int QRSequenceGenerator::GetBinaryReversedInteger ( int  in_val) const
inlineprotected

Definition at line 58 of file qrsequence.h.

58  {
59  int bit_pos = num_bits_;
60  int out_val = 0;
61  while(bit_pos--) {
62  // Set the value of the last bit.
63  out_val |= (in_val & 0x1);
64  if (bit_pos > 0) {
65  // Left-shift output value to prepare for storing the next bit.
66  out_val <<= 1;
67  }
68  // Right-shift input value to prepare for retrieving the next bit.
69  in_val >>= 1;
70  }
71  return out_val;
72  }

◆ GetVal()

int QRSequenceGenerator::GetVal ( )
inline

Definition at line 41 of file qrsequence.h.

41  {
42  const int kInvalidVal = -1;
43  const int kMaxNaturalNumberValue = 1 << num_bits_;
44  if (next_num_ >= kMaxNaturalNumberValue)
45  return kInvalidVal;
46  int n = next_num_;
47 
48  while (next_num_ < kMaxNaturalNumberValue) {
50  if (n < N_) break;
51  }
52  return (next_num_ > kMaxNaturalNumberValue) ? kInvalidVal : n;
53  }
int GetBinaryReversedInteger(int in_val) const
Definition: qrsequence.h:58

Member Data Documentation

◆ N_

int QRSequenceGenerator::N_
protected

Definition at line 73 of file qrsequence.h.

◆ next_num_

int QRSequenceGenerator::next_num_
protected

Definition at line 75 of file qrsequence.h.

◆ num_bits_

int QRSequenceGenerator::num_bits_
protected

Definition at line 77 of file qrsequence.h.


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