#include <intfeaturespace.h>
Definition at line 36 of file intfeaturespace.h.
◆ IntFeatureSpace()
tesseract::IntFeatureSpace::IntFeatureSpace |
( |
| ) |
|
◆ Index()
◆ IndexAndSortFeatures()
void tesseract::IntFeatureSpace::IndexAndSortFeatures |
( |
const INT_FEATURE_STRUCT * |
features, |
|
|
int |
num_features, |
|
|
std::vector< int > * |
sorted_features |
|
) |
| const |
Definition at line 68 of file intfeaturespace.cpp.
69 {
70 sorted_features->clear();
71 for (int f = 0; f < num_features; ++f) {
72 sorted_features->push_back(
Index(features[f]));
73 }
74 std::sort(sorted_features->begin(), sorted_features->end());
75}
int Index(const INT_FEATURE_STRUCT &f) const
◆ IndexFeatures()
void tesseract::IntFeatureSpace::IndexFeatures |
( |
const INT_FEATURE_STRUCT * |
features, |
|
|
int |
num_features, |
|
|
std::vector< int > * |
mapped_features |
|
) |
| const |
Definition at line 58 of file intfeaturespace.cpp.
59 {
60 mapped_features->clear();
61 for (int f = 0; f < num_features; ++f) {
62 mapped_features->push_back(
Index(features[f]));
63 }
64}
◆ Init()
void tesseract::IntFeatureSpace::Init |
( |
uint8_t |
xbuckets, |
|
|
uint8_t |
ybuckets, |
|
|
uint8_t |
thetabuckets |
|
) |
| |
◆ PositionFromBuckets()
INT_FEATURE_STRUCT tesseract::IntFeatureSpace::PositionFromBuckets |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
theta |
|
) |
| const |
|
protected |
Definition at line 114 of file intfeaturespace.cpp.
114 {
118 return pos;
119}
const int kIntFeatureExtent
int DivRounded(int a, int b)
◆ PositionFromIndex()
Definition at line 51 of file intfeaturespace.cpp.
51 {
54}
INT_FEATURE_STRUCT PositionFromBuckets(int x, int y, int theta) const
◆ Serialize()
bool tesseract::IntFeatureSpace::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 36 of file intfeaturespace.cpp.
36 {
38 return false;
39 }
41 return false;
42 }
44 return false;
45 }
46 return true;
47}
◆ Size()
int tesseract::IntFeatureSpace::Size |
( |
| ) |
const |
|
inline |
◆ ThetaBucket()
int tesseract::IntFeatureSpace::ThetaBucket |
( |
int |
theta | ) |
const |
|
inlineprotected |
◆ XBucket()
int tesseract::IntFeatureSpace::XBucket |
( |
int |
x | ) |
const |
|
inlineprotected |
Definition at line 75 of file intfeaturespace.h.
75 {
78 }
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
◆ XYToFeatureIndex()
int tesseract::IntFeatureSpace::XYToFeatureIndex |
( |
int |
x, |
|
|
int |
y |
|
) |
| const |
Definition at line 79 of file intfeaturespace.cpp.
79 {
80
81 INT_FEATURE_STRUCT feature(
x,
y, 0);
82 int index = -1;
83 for (int theta = 0; theta <= UINT8_MAX && index < 0; ++theta) {
84 feature.Theta = theta;
85 index =
Index(feature);
86 }
87 if (index < 0) {
88 tprintf(
"(%d,%d) does not exist in feature space!\n",
x,
y);
89 return -1;
90 }
92 tprintf(
"Click at (%d, %d) ->(%d, %d), ->(%d, %d)\n",
x,
y, feature.X, feature.Y,
x - feature.X,
94
97 if (
x != 0 ||
y != 0) {
98 double angle = atan2(
static_cast<double>(
y),
static_cast<double>(
x)) + M_PI;
100 feature.Theta = static_cast<uint8_t>(angle + 0.5);
101 index =
Index(feature);
102 if (index < 0) {
103 tprintf(
"Feature failed to map to a valid index:");
104 feature.print();
105 return -1;
106 }
108 }
109 feature.print();
110 return index;
111}
void tprintf(const char *format,...)
INT_FEATURE_STRUCT PositionFromIndex(int index) const
◆ YBucket()
int tesseract::IntFeatureSpace::YBucket |
( |
int |
y | ) |
const |
|
inlineprotected |
◆ theta_buckets_
uint8_t tesseract::IntFeatureSpace::theta_buckets_ |
|
protected |
◆ x_buckets_
uint8_t tesseract::IntFeatureSpace::x_buckets_ |
|
protected |
◆ y_buckets_
uint8_t tesseract::IntFeatureSpace::y_buckets_ |
|
protected |
The documentation for this class was generated from the following files: