#include <intfeaturedist.h>
Definition at line 39 of file intfeaturedist.h.
◆ IntFeatureDist()
tesseract::IntFeatureDist::IntFeatureDist |
( |
| ) |
|
Definition at line 25 of file intfeaturedist.cpp.
26 : size_(0), total_feature_weight_(0.0),
27 feature_map_(
nullptr), features_(
nullptr),
28 features_delta_one_(
nullptr), features_delta_two_(
nullptr) {
◆ ~IntFeatureDist()
tesseract::IntFeatureDist::~IntFeatureDist |
( |
| ) |
|
◆ DebugFeatureDistance()
double tesseract::IntFeatureDist::DebugFeatureDistance |
( |
const GenericVector< int > & |
features | ) |
const |
Definition at line 98 of file intfeaturedist.cpp.
100 const int num_test_features = features.
size();
101 const double denominator = total_feature_weight_ + num_test_features;
102 double misses = denominator;
103 for (
int i = 0; i < num_test_features; ++i) {
104 const int index = features[i];
105 const double weight = 1.0;
107 tprintf(
"Testing feature weight %g:", weight);
109 if (features_[index]) {
111 misses -= 2.0 * weight;
113 }
else if (features_delta_one_[index]) {
114 misses -= 1.5 * weight;
116 }
else if (features_delta_two_[index]) {
118 misses -= 1.0 * weight;
125 for (
int i = 0; i < size_; ++i) {
131 tprintf(
"\nMinus one features:");
132 for (
int i = 0; i < size_; ++i) {
133 if (features_delta_one_[i]) {
138 tprintf(
"\nMinus two features:");
139 for (
int i = 0; i < size_; ++i) {
140 if (features_delta_two_[i]) {
146 return misses / denominator;
◆ FeatureDistance()
double tesseract::IntFeatureDist::FeatureDistance |
( |
const GenericVector< int > & |
features | ) |
const |
Definition at line 75 of file intfeaturedist.cpp.
77 const int num_test_features = features.
size();
78 const double denominator = total_feature_weight_ + num_test_features;
79 double misses = denominator;
80 for (
int i = 0; i < num_test_features; ++i) {
81 const int index = features[i];
82 const double weight = 1.0;
83 if (features_[index]) {
85 misses -= 2.0 * weight;
86 }
else if (features_delta_one_[index]) {
87 misses -= 1.5 * weight;
88 }
else if (features_delta_two_[index]) {
90 misses -= 1.0 * weight;
93 return misses / denominator;
◆ Init()
void tesseract::IntFeatureDist::Init |
( |
const IntFeatureMap * |
feature_map | ) |
|
Definition at line 36 of file intfeaturedist.cpp.
37 size_ = feature_map->sparse_size();
39 feature_map_ = feature_map;
40 features_ =
new bool[size_];
41 features_delta_one_ =
new bool[size_];
42 features_delta_two_ =
new bool[size_];
43 memset(features_,
false, size_ *
sizeof(features_[0]));
44 memset(features_delta_one_,
false, size_ *
sizeof(features_delta_one_[0]));
45 memset(features_delta_two_,
false, size_ *
sizeof(features_delta_two_[0]));
46 total_feature_weight_ = 0.0;
◆ Set()
void tesseract::IntFeatureDist::Set |
( |
const GenericVector< int > & |
indexed_features, |
|
|
int |
canonical_count, |
|
|
bool |
value |
|
) |
| |
Definition at line 51 of file intfeaturedist.cpp.
53 total_feature_weight_ = canonical_count;
54 for (
int i = 0; i < indexed_features.
size(); ++i) {
55 const int f = indexed_features[i];
57 for (
int dir = -kNumOffsetMaps; dir <= kNumOffsetMaps; ++dir) {
58 if (dir == 0)
continue;
61 features_delta_one_[mapped_f] = value;
62 for (
int dir2 = -kNumOffsetMaps; dir2 <= kNumOffsetMaps; ++dir2) {
63 if (dir2 == 0)
continue;
64 const int mapped_f2 = feature_map_->
OffsetFeature(mapped_f, dir2);
66 features_delta_two_[mapped_f2] = value;
The documentation for this class was generated from the following files: