26 : x_buckets_(0), y_buckets_(0), theta_buckets_(0) {
74 for (
int f = 0; f < num_features; ++f)
84 for (
int f = 0; f < num_features; ++f)
86 sorted_features->
sort();
95 for (
int theta = 0; theta <=
MAX_UINT8 && index < 0; ++theta) {
96 feature.
Theta = theta;
97 index =
Index(feature);
100 tprintf(
"(%d,%d) does not exist in feature space!\n", x, y);
104 tprintf(
"Click at (%d, %d) ->(%d, %d), ->(%d, %d)\n",
105 x, y, feature.
X, feature.
Y, x - feature.
X, y - feature.
Y);
109 if (x != 0 || y != 0) {
110 double angle = atan2(static_cast<double>(y), static_cast<double>(x)) +
PI;
112 feature.
Theta =
static_cast<uinT8>(angle + 0.5);
113 index =
Index(feature);
115 tprintf(
"Feature failed to map to a valid index:");
int XYToFeatureIndex(int x, int y) const
INT_FEATURE_STRUCT PositionFromBuckets(int x, int y, int theta) const
void IndexFeatures(const INT_FEATURE_STRUCT *features, int num_features, GenericVector< int > *mapped_features) const
bool Serialize(FILE *fp) const
bool DeSerialize(bool swap, FILE *fp)
int Index(const INT_FEATURE_STRUCT &f) const
void IndexAndSortFeatures(const INT_FEATURE_STRUCT *features, int num_features, GenericVector< int > *sorted_features) const
INT_FEATURE_STRUCT PositionFromIndex(int index) const
void Init(uinT8 xbuckets, uinT8 ybuckets, uinT8 thetabuckets)
int DivRounded(int a, int b)
const int kIntFeatureExtent