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