|
tesseract 3.04.01
|
#include <intfeaturedist.h>
Public Member Functions | |
| IntFeatureDist () | |
| ~IntFeatureDist () | |
| void | Init (const IntFeatureMap *feature_map) |
| void | Set (const GenericVector< int > &indexed_features, int canonical_count, bool value) |
| double | FeatureDistance (const GenericVector< int > &features) const |
| double | DebugFeatureDistance (const GenericVector< int > &features) const |
Definition at line 39 of file intfeaturedist.h.
| usr src packages BUILD tesseract classify intfeaturedist cpp usr src packages BUILD tesseract classify intfeaturedist cpp tesseract::IntFeatureDist::IntFeatureDist | ( | ) |
Definition at line 27 of file intfeaturedist.cpp.
{
}
IntFeatureDist::~IntFeatureDist() {
| tesseract::IntFeatureDist::~IntFeatureDist | ( | ) |
Definition at line 33 of file intfeaturedist.cpp.
| double tesseract::IntFeatureDist::DebugFeatureDistance | ( | const GenericVector< int > & | features | ) | const |
Definition at line 100 of file intfeaturedist.cpp.
{
int index = features[i];
double weight = 1.0;
INT_FEATURE_STRUCT f = feature_map_->InverseMapFeature(features[i]);
tprintf("Testing feature weight %g:", weight);
f.print();
if (features_[index]) {
// A perfect match.
misses -= 2.0 * weight;
tprintf("Perfect hit\n");
} else if (features_delta_one_[index]) {
misses -= 1.5 * weight;
tprintf("-1 hit\n");
} else if (features_delta_two_[index]) {
// A near miss.
misses -= 1.0 * weight;
tprintf("-2 hit\n");
} else {
tprintf("Total miss\n");
}
}
tprintf("Features present:");
for (int i = 0; i < size_; ++i) {
if (features_[i]) {
INT_FEATURE_STRUCT f = feature_map_->InverseMapFeature(i);
f.print();
}
}
tprintf("\nMinus one features:");
for (int i = 0; i < size_; ++i) {
if (features_delta_one_[i]) {
INT_FEATURE_STRUCT f = feature_map_->InverseMapFeature(i);
f.print();
}
}
tprintf("\nMinus two features:");
for (int i = 0; i < size_; ++i) {
if (features_delta_two_[i]) {
INT_FEATURE_STRUCT f = feature_map_->InverseMapFeature(i);
f.print();
}
}
tprintf("\n");
return misses / denominator;
}
// Clear all data.
| double tesseract::IntFeatureDist::FeatureDistance | ( | const GenericVector< int > & | features | ) | const |
Definition at line 77 of file intfeaturedist.cpp.
{
int index = features[i];
double weight = 1.0;
if (features_[index]) {
// A perfect match.
misses -= 2.0 * weight;
} else if (features_delta_one_[index]) {
misses -= 1.5 * weight;
} else if (features_delta_two_[index]) {
// A near miss.
misses -= 1.0 * weight;
}
}
return misses / denominator;
}
// Compute the distance between the given feature vector and the last
| void tesseract::IntFeatureDist::Init | ( | const IntFeatureMap * | feature_map | ) |
Definition at line 38 of file intfeaturedist.cpp.
| void tesseract::IntFeatureDist::Set | ( | const GenericVector< int > & | indexed_features, |
| int | canonical_count, | ||
| bool | value | ||
| ) |
Definition at line 53 of file intfeaturedist.cpp.
{
int f = indexed_features[i];
features_[f] = value;
for (int dir = -kNumOffsetMaps; dir <= kNumOffsetMaps; ++dir) {
if (dir == 0) continue;
int mapped_f = feature_map_->OffsetFeature(f, dir);
if (mapped_f >= 0) {
features_delta_one_[mapped_f] = value;
for (int dir2 = -kNumOffsetMaps; dir2 <= kNumOffsetMaps; ++dir2) {
if (dir2 == 0) continue;
int mapped_f2 = feature_map_->OffsetFeature(mapped_f, dir2);
if (mapped_f2 >= 0)
features_delta_two_[mapped_f2] = value;
}
}
}
}
}
// Compute the distance between the given feature vector and the last