tesseract  5.0.0
QRSequenceGenerator Class Reference

#include <qrsequence.h>

Inheritance diagram for QRSequenceGenerator:
tesseract::TestableQRSequenceGenerator

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 31 of file qrsequence.h.

Constructor & Destructor Documentation

◆ QRSequenceGenerator()

QRSequenceGenerator::QRSequenceGenerator ( int  N)
inlineexplicit

Definition at line 34 of file qrsequence.h.

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

Member Function Documentation

◆ GetBinaryReversedInteger()

int QRSequenceGenerator::GetBinaryReversedInteger ( int  in_val) const
inlineprotected

Definition at line 60 of file qrsequence.h.

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

◆ GetVal()

int QRSequenceGenerator::GetVal ( )
inline

Definition at line 40 of file qrsequence.h.

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

Member Data Documentation

◆ N_

int QRSequenceGenerator::N_
protected

Definition at line 75 of file qrsequence.h.

◆ next_num_

int QRSequenceGenerator::next_num_
protected

Definition at line 77 of file qrsequence.h.

◆ num_bits_

int QRSequenceGenerator::num_bits_
protected

Definition at line 79 of file qrsequence.h.


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