35 : mapping_changed_(true), compact_size_(0) {
36 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
37 offset_plus_[dir] =
nullptr;
38 offset_minus_[dir] =
nullptr;
48 return feature_space_.
Index(f);
64 feature_map_.
Merge(-1, map_feature);
65 mapping_changed_ =
true;
75 mapping_changed_ =
false;
82 if (dir.
x() == 0.0f && dir.
y() == 0.0f)
85 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
86 delete [] offset_plus_[dir];
87 delete [] offset_minus_[dir];
91 for (
int dir = 1; dir <= kNumOffsetMaps; ++dir) {
93 int offset_index = ComputeOffsetFeature(i, dir);
94 offset_plus_[dir - 1][i] = offset_index;
95 offset_index = ComputeOffsetFeature(i, -dir);
96 offset_minus_[dir - 1][i] = offset_index;
114 if (dir > 0 && dir <= kNumOffsetMaps)
115 return offset_plus_[dir - 1][index_feature];
116 else if (dir < 0 && -dir <= kNumOffsetMaps)
117 return offset_minus_[-dir - 1][index_feature];
119 return index_feature;
126 #ifdef EXPERIMENT_ON // This code is commented out as SampleIterator and
134 feature_map_.
Init(feature_space_.
Size(),
false);
135 int total_samples = 0;
142 int num_features = features.
size();
143 for (
int f = 0; f < num_features; ++f)
144 feature_map_.
SetMap(features[f],
true);
147 feature_map_.
Setup();
149 mapping_changed_ =
true;
151 tprintf(
"%d non-zero features found in %d samples\n",
152 compact_size_, total_samples);
153 return compact_size_;
160 if (mapping_changed_) {
166 mapping_changed_ =
false;
168 return compact_size_;
174 for (
int i = 0; i < map_features.
size(); ++i) {
180 void IntFeatureMap::Clear() {
181 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
182 delete [] offset_plus_[dir];
183 delete [] offset_minus_[dir];
184 offset_plus_[dir] =
nullptr;
185 offset_minus_[dir] =
nullptr;
201 int IntFeatureMap::ComputeOffsetFeature(
int index_feature,
int dir)
const {
205 return index_feature;
206 }
else if (dir == 1 || dir == -1) {
208 FCOORD rotation90(0.0f, 1.0f);
209 feature_dir.
rotate(rotation90);
212 double x_pos = f.
X + feature_dir.
x() * (m * dir);
213 double y_pos = f.
Y + feature_dir.
y() * (m * dir);
216 if (x >= 0 && x <= UINT8_MAX && y >= 0 && y <= UINT8_MAX) {
222 if (offset_index != index_feature && offset_index >= 0)
228 }
else if (dir == 2 || dir == -2) {
231 int theta = f.
Theta + m * dir / 2;
237 if (offset_index != index_feature && offset_index >= 0)