36 : mapping_changed_(true), compact_size_(0) {
37 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
38 offset_plus_[dir] =
NULL;
39 offset_minus_[dir] =
NULL;
49 return feature_space_.
Index(f);
65 feature_map_.
Merge(-1, map_feature);
66 mapping_changed_ =
true;
76 mapping_changed_ =
false;
78 feature_map_.
Init(sparse_size,
true);
83 if (dir.
x() == 0.0f && dir.
y() == 0.0f)
86 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
87 delete [] offset_plus_[dir];
88 delete [] offset_minus_[dir];
92 for (
int dir = 1; dir <= kNumOffsetMaps; ++dir) {
94 int offset_index = ComputeOffsetFeature(i, dir);
95 offset_plus_[dir - 1][i] = offset_index;
96 offset_index = ComputeOffsetFeature(i, -dir);
97 offset_minus_[dir - 1][i] = offset_index;
115 if (dir > 0 && dir <= kNumOffsetMaps)
116 return offset_plus_[dir - 1][index_feature];
117 else if (dir < 0 && -dir <= kNumOffsetMaps)
118 return offset_minus_[-dir - 1][index_feature];
120 return index_feature;
127 #ifdef EXPERIMENT_ON // This code is commented out as SampleIterator and
135 feature_map_.
Init(feature_space_.
Size(),
false);
136 int total_samples = 0;
143 int num_features = features.
size();
144 for (
int f = 0;
f < num_features; ++
f)
145 feature_map_.
SetMap(features[
f],
true);
148 feature_map_.
Setup();
150 mapping_changed_ =
true;
152 tprintf(
"%d non-zero features found in %d samples\n",
153 compact_size_, total_samples);
154 return compact_size_;
161 if (mapping_changed_) {
167 mapping_changed_ =
false;
169 return compact_size_;
175 for (
int i = 0; i < map_features.
size(); ++i) {
181 void IntFeatureMap::Clear() {
182 for (
int dir = 0; dir < kNumOffsetMaps; ++dir) {
183 delete [] offset_plus_[dir];
184 delete [] offset_minus_[dir];
185 offset_plus_[dir] =
NULL;
186 offset_minus_[dir] =
NULL;
202 int IntFeatureMap::ComputeOffsetFeature(
int index_feature,
int dir)
const {
206 return index_feature;
207 }
else if (dir == 1 || dir == -1) {
209 FCOORD rotation90(0.0f, 1.0f);
210 feature_dir.
rotate(rotation90);
213 double x_pos = f.
X + feature_dir.
x() * (m * dir);
214 double y_pos = f.
Y + feature_dir.
y() * (m * dir);
217 if (x >= 0 && x <= MAX_UINT8 && y >= 0 && y <=
MAX_UINT8) {
223 if (offset_index != index_feature && offset_index >= 0)
229 }
else if (dir == 2 || dir == -2) {
232 int theta = f.
Theta + m * dir / 2;
238 if (offset_index != index_feature && offset_index >= 0)