#include <indexmapbidi.h>
Definition at line 104 of file indexmapbidi.h.
◆ ~IndexMapBiDi()
tesseract::IndexMapBiDi::~IndexMapBiDi |
( |
| ) |
|
|
overridedefault |
◆ CompleteMerges()
void tesseract::IndexMapBiDi::CompleteMerges |
( |
| ) |
|
Definition at line 177 of file indexmapbidi.cpp.
177 {
178
179 int compact_size = 0;
180 for (
int &
i : sparse_map_) {
181 int compact_index = MasterCompactIndex(
i);
183 if (compact_index >= compact_size) {
184 compact_size = compact_index + 1;
185 }
186 }
187
190 for (
size_t i = 0;
i < sparse_map_.size(); ++
i) {
191 if (sparse_map_[
i] >= 0) {
194 }
195 }
196 }
197
198
199 std::vector<int32_t> tmp_compact_map(compact_size, -1);
200 compact_size = 0;
203 tmp_compact_map[
i] = compact_size;
205 }
206 }
208
209 for (
int &
i : sparse_map_) {
211 i = tmp_compact_map[
i];
212 }
213 }
214}
std::vector< int32_t > compact_map_
◆ CopyFrom()
void tesseract::IndexMapBiDi::CopyFrom |
( |
const IndexMapBiDi & |
src | ) |
|
◆ DeSerialize()
bool tesseract::IndexMapBiDi::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 236 of file indexmapbidi.cpp.
236 {
238 return false;
239 }
240 std::vector<int32_t> remaining_pairs;
242 return false;
243 }
244 sparse_map_.clear();
248 }
249 for (
size_t i = 0;
i < remaining_pairs.size(); ++
i) {
250 int sparse_index = remaining_pairs[
i++];
251 sparse_map_[sparse_index] = remaining_pairs[
i];
252 }
253 return true;
254}
bool DeSerialize(bool swap, FILE *fp, std::vector< T > &data)
bool DeSerialize(bool swap, FILE *fp)
◆ Init()
void tesseract::IndexMapBiDi::Init |
( |
int |
size, |
|
|
bool |
all_mapped |
|
) |
| |
Definition at line 97 of file indexmapbidi.cpp.
97 {
98 if (!all_mapped) {
99 sparse_map_.clear();
100 }
101 sparse_map_.resize(size, -1);
102 if (all_mapped) {
103 for (
int i = 0;
i < size; ++
i) {
105 }
106 }
107}
◆ InitAndSetupRange()
void tesseract::IndexMapBiDi::InitAndSetupRange |
( |
int |
sparse_size, |
|
|
int |
start, |
|
|
int |
end |
|
) |
| |
Definition at line 85 of file indexmapbidi.cpp.
85 {
86 Init(sparse_size,
false);
87 for (
int i = start;
i < end; ++
i) {
89 }
91}
void Init(int size, bool all_mapped)
void SetMap(int sparse_index, bool mapped)
◆ IsCompactDeleted()
bool tesseract::IndexMapBiDi::IsCompactDeleted |
( |
int |
index | ) |
const |
|
inline |
Definition at line 132 of file indexmapbidi.h.
132 {
133 return MasterCompactIndex(index) < 0;
134 }
◆ MapFeatures()
int tesseract::IndexMapBiDi::MapFeatures |
( |
const std::vector< int > & |
sparse, |
|
|
std::vector< int > * |
compact |
|
) |
| const |
Definition at line 261 of file indexmapbidi.cpp.
261 {
262 compact->clear();
263 int num_features = sparse.size();
264 int missed_features = 0;
265 int prev_good_feature = -1;
266 for (int f = 0; f < num_features; ++f) {
267 int feature = sparse_map_[sparse[f]];
268 if (feature >= 0) {
269 if (feature != prev_good_feature) {
270 compact->push_back(feature);
271 prev_good_feature = feature;
272 }
273 } else {
274 ++missed_features;
275 }
276 }
277 return missed_features;
278}
◆ Merge()
bool tesseract::IndexMapBiDi::Merge |
( |
int |
compact_index1, |
|
|
int |
compact_index2 |
|
) |
| |
Definition at line 144 of file indexmapbidi.cpp.
144 {
145
146 compact_index1 = MasterCompactIndex(compact_index1);
147 compact_index2 = MasterCompactIndex(compact_index2);
148
149 if (compact_index1 > compact_index2) {
150 int tmp = compact_index1;
151 compact_index1 = compact_index2;
152 compact_index2 = tmp;
153 } else if (compact_index1 == compact_index2) {
154 return false;
155 }
156
157
158
159
160 sparse_map_[
compact_map_[compact_index2]] = compact_index1;
161 if (compact_index1 >= 0) {
163 }
164 return true;
165}
◆ Serialize()
bool tesseract::IndexMapBiDi::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 217 of file indexmapbidi.cpp.
217 {
219 return false;
220 }
221
222
223
224 std::vector<int32_t> remaining_pairs;
225 for (
unsigned i = 0;
i < sparse_map_.size(); ++
i) {
226 if (sparse_map_[
i] >= 0 &&
static_cast<unsigned>(
compact_map_[sparse_map_[
i]]) !=
i) {
227 remaining_pairs.push_back(
i);
228 remaining_pairs.push_back(sparse_map_[
i]);
229 }
230 }
232}
bool Serialize(FILE *fp, const std::vector< T > &data)
bool Serialize(FILE *fp) const
◆ SetMap()
void tesseract::IndexMapBiDi::SetMap |
( |
int |
sparse_index, |
|
|
bool |
mapped |
|
) |
| |
Definition at line 110 of file indexmapbidi.cpp.
110 {
111 sparse_map_[sparse_index] = mapped ? 0 : -1;
112}
◆ Setup()
void tesseract::IndexMapBiDi::Setup |
( |
| ) |
|
Definition at line 117 of file indexmapbidi.cpp.
117 {
118 int compact_size = 0;
119 for (
int &
i : sparse_map_) {
122 }
123 }
126 for (
size_t i = 0;
i < sparse_map_.size(); ++
i) {
127 if (sparse_map_[
i] >= 0) {
129 }
130 }
132}
◆ SparseSize()
int tesseract::IndexMapBiDi::SparseSize |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ SparseToCompact()
int tesseract::IndexMapBiDi::SparseToCompact |
( |
int |
sparse_index | ) |
const |
|
inlineoverridevirtual |
The documentation for this class was generated from the following files:
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/ccutil/indexmapbidi.h
- /media/home/debian/src/github/tesseract-ocr/tesseract/src/ccutil/indexmapbidi.cpp