1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<html xmlns="http://www.w3.org/1999/xhtml">
4
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6
<title>tesseract: tesseract::SampleIterator Class Reference</title>
8
<link href="tabs.css" rel="stylesheet" type="text/css"/>
9
<link href="doxygen.css" rel="stylesheet" type="text/css" />
10
<link href="navtree.css" rel="stylesheet" type="text/css"/>
11
<script type="text/javascript" src="jquery.js"></script>
12
<script type="text/javascript" src="resize.js"></script>
13
<script type="text/javascript" src="navtree.js"></script>
14
<script type="text/javascript">
15
$(document).ready(initResizable);
17
<link href="search/search.css" rel="stylesheet" type="text/css"/>
18
<script type="text/javascript" src="search/search.js"></script>
19
<script type="text/javascript">
20
$(document).ready(function() { searchBox.OnSelectItem(0); });
25
<div id="top"><!-- do not remove this div! -->
29
<table cellspacing="0" cellpadding="0">
31
<tr style="height: 56px;">
34
<td style="padding-left: 0.5em;">
35
<div id="projectname">tesseract
36
 <span id="projectnumber">3.03</span>
48
<!-- Generated by Doxygen 1.7.6.1 -->
49
<script type="text/javascript">
50
var searchBox = new SearchBox("searchBox", "search",false,'Search');
52
<div id="navrow1" class="tabs">
54
<li><a href="index.html"><span>Main Page</span></a></li>
55
<li><a href="pages.html"><span>Related Pages</span></a></li>
56
<li><a href="modules.html"><span>Modules</span></a></li>
57
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
58
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
59
<li><a href="files.html"><span>Files</span></a></li>
61
<div id="MSearchBox" class="MSearchBoxInactive">
63
<img id="MSearchSelect" src="search/mag_sel.png"
64
onmouseover="return searchBox.OnSearchSelectShow()"
65
onmouseout="return searchBox.OnSearchSelectHide()"
67
<input type="text" id="MSearchField" value="Search" accesskey="S"
68
onfocus="searchBox.OnSearchFieldFocus(true)"
69
onblur="searchBox.OnSearchFieldFocus(false)"
70
onkeyup="searchBox.OnSearchFieldChange(event)"/>
71
</span><span class="right">
72
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
78
<div id="navrow2" class="tabs2">
80
<li><a href="annotated.html"><span>Class List</span></a></li>
81
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
82
<li><a href="functions.html"><span>Class Members</span></a></li>
86
<div id="side-nav" class="ui-resizable side-nav-resizable">
88
<div id="nav-tree-contents">
91
<div id="splitbar" style="-moz-user-select:none;"
92
class="ui-resizable-handle">
95
<script type="text/javascript">
96
initNavTree('a00526.html','');
98
<div id="doc-content">
100
<div class="summary">
101
<a href="#pub-methods">Public Member Functions</a> </div>
102
<div class="headertitle">
103
<div class="title">tesseract::SampleIterator Class Reference</div> </div>
105
<div class="contents">
106
<!-- doxytag: class="tesseract::SampleIterator" -->
107
<p><code>#include <<a class="el" href="a00937_source.html">sampleiterator.h</a>></code></p>
109
<p><a href="a01803.html">List of all members.</a></p>
110
<table class="memberdecls">
111
<tr><td colspan="2"><h2><a name="pub-methods"></a>
112
Public Member Functions</h2></td></tr>
113
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a9789d39f648bb3942e69fb42402b173c">SampleIterator</a> ()</td></tr>
114
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a6a7e5ec1f292ab6ecea1f3385496ec37">~SampleIterator</a> ()</td></tr>
115
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#ab9b74fc9ac303c34474b69ee69f2d663">Clear</a> ()</td></tr>
116
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a0cdb514895d01dff26b51a2e5bc1b0ea">Init</a> (const <a class="el" href="a00416.html">IndexMapBiDi</a> *<a class="el" href="a00526.html#a1fdfa33c330477eb7c5eef8ca47fd40c">charset_map</a>, const <a class="el" href="a00544.html">ShapeTable</a> *<a class="el" href="a00526.html#aeae6fe3f5607f0e0ff9f82151d096ced">shape_table</a>, bool randomize, <a class="el" href="a00631.html">TrainingSampleSet</a> *<a class="el" href="a00526.html#a11e0a8f5f60216b68c3fe6528d551295">sample_set</a>)</td></tr>
117
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a> ()</td></tr>
118
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">AtEnd</a> () const </td></tr>
119
<tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="a00630.html">TrainingSample</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a274fa0bca10b58d7efddebde0338a698">GetSample</a> () const </td></tr>
120
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00630.html">TrainingSample</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a0941312fec55859dc29a1b32b0e298cd">MutableSample</a> () const </td></tr>
121
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a3651237953d616f7d27f4ed46106707c">GlobalSampleIndex</a> () const </td></tr>
122
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a745b2bf5f8956bc1233e28f9b1c5b639">GetCompactClassID</a> () const </td></tr>
123
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a35e0355b17965fef669f2bd84ea624a7">GetSparseClassID</a> () const </td></tr>
124
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a> ()</td></tr>
125
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a95b17d95d0777709dee9606e57a6aad1">CompactCharsetSize</a> () const </td></tr>
126
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#ad575eda15498de5a5de614dbcfa4d0aa">SparseCharsetSize</a> () const </td></tr>
127
<tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="a00416.html">IndexMapBiDi</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a1fdfa33c330477eb7c5eef8ca47fd40c">charset_map</a> () const </td></tr>
128
<tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="a00544.html">ShapeTable</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#aeae6fe3f5607f0e0ff9f82151d096ced">shape_table</a> () const </td></tr>
129
<tr><td class="memItemLeft" align="right" valign="top">const <a class="el" href="a00631.html">TrainingSampleSet</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a11e0a8f5f60216b68c3fe6528d551295">sample_set</a> () const </td></tr>
130
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a476d245234d73a6c9ef7c85b57148a27">MapSampleFeatures</a> (const <a class="el" href="a00429.html">IntFeatureMap</a> &feature_map)</td></tr>
131
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#a82e48b99ecac34b9e0dbf8a96521bb4e">UniformSamples</a> ()</td></tr>
132
<tr><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><a class="el" href="a00526.html#ac0a70c42261385f21d97c699ff181fad">NormalizeSamples</a> ()</td></tr>
134
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
135
<div class="textblock">
136
<p>Definition at line <a class="el" href="a00937_source.html#l00092">92</a> of file <a class="el" href="a00937_source.html">sampleiterator.h</a>.</p>
137
</div><hr/><h2>Constructor & Destructor Documentation</h2>
138
<a class="anchor" id="a9789d39f648bb3942e69fb42402b173c"></a><!-- doxytag: member="tesseract::SampleIterator::SampleIterator" ref="a9789d39f648bb3942e69fb42402b173c" args="()" -->
139
<div class="memitem">
140
<div class="memproto">
141
<table class="memname">
143
<td class="memname"><a class="el" href="a00526.html#a9789d39f648bb3942e69fb42402b173c">tesseract::SampleIterator::SampleIterator</a> </td>
145
<td class="paramname"></td><td>)</td>
152
<p>Definition at line <a class="el" href="a00936_source.html#l00027">27</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
153
<div class="fragment"><pre class="fragment"> : charset_map_(NULL),
156
randomize_(<span class="keyword">false</span>),
157
owned_shape_table_(NULL) {
159
<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>();
164
<a class="anchor" id="a6a7e5ec1f292ab6ecea1f3385496ec37"></a><!-- doxytag: member="tesseract::SampleIterator::~SampleIterator" ref="a6a7e5ec1f292ab6ecea1f3385496ec37" args="()" -->
165
<div class="memitem">
166
<div class="memproto">
167
<table class="memname">
169
<td class="memname"><a class="el" href="a00526.html#a6a7e5ec1f292ab6ecea1f3385496ec37">tesseract::SampleIterator::~SampleIterator</a> </td>
171
<td class="paramname"></td><td>)</td>
178
<p>Definition at line <a class="el" href="a00936_source.html#l00037">37</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
179
<div class="fragment"><pre class="fragment"> {
180
<a class="code" href="a00526.html#ab9b74fc9ac303c34474b69ee69f2d663">Clear</a>();
185
<hr/><h2>Member Function Documentation</h2>
186
<a class="anchor" id="a4dde9bf911b04c848fbdc4cca8699b70"></a><!-- doxytag: member="tesseract::SampleIterator::AtEnd" ref="a4dde9bf911b04c848fbdc4cca8699b70" args="() const " -->
187
<div class="memitem">
188
<div class="memproto">
189
<table class="memname">
191
<td class="memname">bool <a class="el" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">tesseract::SampleIterator::AtEnd</a> </td>
193
<td class="paramname"></td><td>)</td>
200
<p>Definition at line <a class="el" href="a00936_source.html#l00099">99</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
201
<div class="fragment"><pre class="fragment"> {
202
<span class="keywordflow">return</span> shape_index_ >= num_shapes_;
207
<a class="anchor" id="a90e5190efbff41c67519ba29fa59186f"></a><!-- doxytag: member="tesseract::SampleIterator::Begin" ref="a90e5190efbff41c67519ba29fa59186f" args="()" -->
208
<div class="memitem">
209
<div class="memproto">
210
<table class="memname">
212
<td class="memname">void <a class="el" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">tesseract::SampleIterator::Begin</a> </td>
214
<td class="paramname"></td><td>)</td>
221
<p>Definition at line <a class="el" href="a00936_source.html#l00087">87</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
222
<div class="fragment"><pre class="fragment"> {
224
shape_char_index_ = 0;
225
num_shape_chars_ = 0;
226
shape_font_index_ = 0;
227
num_shape_fonts_ = 0;
230
<span class="comment">// Find the first indexable sample.</span>
231
<a class="code" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a>();
236
<a class="anchor" id="a1fdfa33c330477eb7c5eef8ca47fd40c"></a><!-- doxytag: member="tesseract::SampleIterator::charset_map" ref="a1fdfa33c330477eb7c5eef8ca47fd40c" args="() const " -->
237
<div class="memitem">
238
<div class="memproto">
239
<table class="memname">
241
<td class="memname">const <a class="el" href="a00416.html">IndexMapBiDi</a>& <a class="el" href="a00526.html#a1fdfa33c330477eb7c5eef8ca47fd40c">tesseract::SampleIterator::charset_map</a> </td>
243
<td class="paramname"></td><td>)</td>
244
<td> const<code> [inline]</code></td>
250
<p>Definition at line <a class="el" href="a00937_source.html#l00137">137</a> of file <a class="el" href="a00937_source.html">sampleiterator.h</a>.</p>
251
<div class="fragment"><pre class="fragment"> {
252
<span class="keywordflow">return</span> *charset_map_;
257
<a class="anchor" id="ab9b74fc9ac303c34474b69ee69f2d663"></a><!-- doxytag: member="tesseract::SampleIterator::Clear" ref="ab9b74fc9ac303c34474b69ee69f2d663" args="()" -->
258
<div class="memitem">
259
<div class="memproto">
260
<table class="memname">
262
<td class="memname">void <a class="el" href="a00526.html#ab9b74fc9ac303c34474b69ee69f2d663">tesseract::SampleIterator::Clear</a> </td>
264
<td class="paramname"></td><td>)</td>
271
<p>Definition at line <a class="el" href="a00936_source.html#l00041">41</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
272
<div class="fragment"><pre class="fragment"> {
273
<span class="keyword">delete</span> owned_shape_table_;
274
owned_shape_table_ = NULL;
279
<a class="anchor" id="a95b17d95d0777709dee9606e57a6aad1"></a><!-- doxytag: member="tesseract::SampleIterator::CompactCharsetSize" ref="a95b17d95d0777709dee9606e57a6aad1" args="() const " -->
280
<div class="memitem">
281
<div class="memproto">
282
<table class="memname">
284
<td class="memname">int <a class="el" href="a00526.html#a95b17d95d0777709dee9606e57a6aad1">tesseract::SampleIterator::CompactCharsetSize</a> </td>
286
<td class="paramname"></td><td>)</td>
293
<p>Definition at line <a class="el" href="a00936_source.html#l00196">196</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
294
<div class="fragment"><pre class="fragment"> {
295
<span class="keywordflow">return</span> charset_map_ != NULL ? charset_map_-><a class="code" href="a00415.html#ab2904b1640580ad7ba6b2c14522dc3e8">CompactSize</a>()
296
: <a class="code" href="a00526.html#ad575eda15498de5a5de614dbcfa4d0aa">SparseCharsetSize</a>();
301
<a class="anchor" id="a745b2bf5f8956bc1233e28f9b1c5b639"></a><!-- doxytag: member="tesseract::SampleIterator::GetCompactClassID" ref="a745b2bf5f8956bc1233e28f9b1c5b639" args="() const " -->
302
<div class="memitem">
303
<div class="memproto">
304
<table class="memname">
306
<td class="memname">int <a class="el" href="a00526.html#a745b2bf5f8956bc1233e28f9b1c5b639">tesseract::SampleIterator::GetCompactClassID</a> </td>
308
<td class="paramname"></td><td>)</td>
315
<p>Definition at line <a class="el" href="a00936_source.html#l00142">142</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
316
<div class="fragment"><pre class="fragment"> {
317
<span class="keywordflow">return</span> charset_map_ != NULL ? charset_map_-><a class="code" href="a00416.html#a2c0f96f5d5fad6c9973e1b074fac5a03">SparseToCompact</a>(shape_index_)
318
: <a class="code" href="a00526.html#a35e0355b17965fef669f2bd84ea624a7">GetSparseClassID</a>();
323
<a class="anchor" id="a274fa0bca10b58d7efddebde0338a698"></a><!-- doxytag: member="tesseract::SampleIterator::GetSample" ref="a274fa0bca10b58d7efddebde0338a698" args="() const " -->
324
<div class="memitem">
325
<div class="memproto">
326
<table class="memname">
328
<td class="memname">const <a class="el" href="a00630.html">TrainingSample</a> & <a class="el" href="a00526.html#a274fa0bca10b58d7efddebde0338a698">tesseract::SampleIterator::GetSample</a> </td>
330
<td class="paramname"></td><td>)</td>
337
<p>Definition at line <a class="el" href="a00936_source.html#l00103">103</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
338
<div class="fragment"><pre class="fragment"> {
339
<span class="keywordflow">if</span> (shape_table_ != NULL) {
340
<span class="keyword">const</span> UnicharAndFonts* shape_entry = GetShapeEntry();
341
<span class="keywordtype">int</span> char_id = shape_entry->unichar_id;
342
<span class="keywordtype">int</span> font_id = shape_entry->font_ids[shape_font_index_];
343
<span class="keywordflow">return</span> *sample_set_-><a class="code" href="a00631.html#a8fa00414deb6726dcf6b770df5af6e8a">GetSample</a>(font_id, char_id, sample_index_);
344
} <span class="keywordflow">else</span> {
345
<span class="keywordflow">return</span> *sample_set_-><a class="code" href="a00631.html#a8fa00414deb6726dcf6b770df5af6e8a">GetSample</a>(shape_index_);
351
<a class="anchor" id="a35e0355b17965fef669f2bd84ea624a7"></a><!-- doxytag: member="tesseract::SampleIterator::GetSparseClassID" ref="a35e0355b17965fef669f2bd84ea624a7" args="() const " -->
352
<div class="memitem">
353
<div class="memproto">
354
<table class="memname">
356
<td class="memname">int <a class="el" href="a00526.html#a35e0355b17965fef669f2bd84ea624a7">tesseract::SampleIterator::GetSparseClassID</a> </td>
358
<td class="paramname"></td><td>)</td>
365
<p>Definition at line <a class="el" href="a00936_source.html#l00150">150</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
366
<div class="fragment"><pre class="fragment"> {
367
<span class="keywordflow">return</span> shape_table_ != NULL ? shape_index_ : <a class="code" href="a00526.html#a274fa0bca10b58d7efddebde0338a698">GetSample</a>().<a class="code" href="a00630.html#aa00151c48156e85a61bc11a2b7b2fe02">class_id</a>();
372
<a class="anchor" id="a3651237953d616f7d27f4ed46106707c"></a><!-- doxytag: member="tesseract::SampleIterator::GlobalSampleIndex" ref="a3651237953d616f7d27f4ed46106707c" args="() const " -->
373
<div class="memitem">
374
<div class="memproto">
375
<table class="memname">
377
<td class="memname">int <a class="el" href="a00526.html#a3651237953d616f7d27f4ed46106707c">tesseract::SampleIterator::GlobalSampleIndex</a> </td>
379
<td class="paramname"></td><td>)</td>
386
<p>Definition at line <a class="el" href="a00936_source.html#l00127">127</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
387
<div class="fragment"><pre class="fragment"> {
388
<span class="keywordflow">if</span> (shape_table_ != NULL) {
389
<span class="keyword">const</span> UnicharAndFonts* shape_entry = GetShapeEntry();
390
<span class="keywordtype">int</span> char_id = shape_entry->unichar_id;
391
<span class="keywordtype">int</span> font_id = shape_entry->font_ids[shape_font_index_];
392
<span class="keywordflow">return</span> sample_set_-><a class="code" href="a00631.html#addf858e6da214cd31161a270e4365fe1">GlobalSampleIndex</a>(font_id, char_id, sample_index_);
393
} <span class="keywordflow">else</span> {
394
<span class="keywordflow">return</span> shape_index_;
400
<a class="anchor" id="a0cdb514895d01dff26b51a2e5bc1b0ea"></a><!-- doxytag: member="tesseract::SampleIterator::Init" ref="a0cdb514895d01dff26b51a2e5bc1b0ea" args="(const IndexMapBiDi *charset_map, const ShapeTable *shape_table, bool randomize, TrainingSampleSet *sample_set)" -->
401
<div class="memitem">
402
<div class="memproto">
403
<table class="memname">
405
<td class="memname">void <a class="el" href="a00526.html#a0cdb514895d01dff26b51a2e5bc1b0ea">tesseract::SampleIterator::Init</a> </td>
407
<td class="paramtype">const <a class="el" href="a00416.html">IndexMapBiDi</a> * </td>
408
<td class="paramname"><em>charset_map</em>, </td>
411
<td class="paramkey"></td>
413
<td class="paramtype">const <a class="el" href="a00544.html">ShapeTable</a> * </td>
414
<td class="paramname"><em>shape_table</em>, </td>
417
<td class="paramkey"></td>
419
<td class="paramtype">bool </td>
420
<td class="paramname"><em>randomize</em>, </td>
423
<td class="paramkey"></td>
425
<td class="paramtype"><a class="el" href="a00631.html">TrainingSampleSet</a> * </td>
426
<td class="paramname"><em>sample_set</em> </td>
437
<p>Definition at line <a class="el" href="a00936_source.html#l00047">47</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
438
<div class="fragment"><pre class="fragment"> {
439
<a class="code" href="a00526.html#ab9b74fc9ac303c34474b69ee69f2d663">Clear</a>();
440
charset_map_ = <a class="code" href="a00526.html#a1fdfa33c330477eb7c5eef8ca47fd40c">charset_map</a>;
441
shape_table_ = <a class="code" href="a00526.html#aeae6fe3f5607f0e0ff9f82151d096ced">shape_table</a>;
442
sample_set_ = <a class="code" href="a00526.html#a11e0a8f5f60216b68c3fe6528d551295">sample_set</a>;
443
randomize_ = randomize;
444
<span class="keywordflow">if</span> (shape_table_ == NULL && charset_map_ != NULL) {
445
<span class="comment">// The caller wishes to iterate by class. The easiest way to do this</span>
446
<span class="comment">// is to create a dummy shape_table_ that we will own.</span>
447
<span class="keywordtype">int</span> num_fonts = sample_set_-><a class="code" href="a00631.html#a106d93e244deeb4e10818b80343914b5">NumFonts</a>();
448
owned_shape_table_ = <span class="keyword">new</span> ShapeTable(sample_set_-><a class="code" href="a00631.html#aded0df876324870023182dc4e0a2b28b">unicharset</a>());
449
<span class="keywordtype">int</span> charsetsize = sample_set_-><a class="code" href="a00631.html#aded0df876324870023182dc4e0a2b28b">unicharset</a>().<a class="code" href="a00642.html#aa3e8073ebaf3e0022654c45f27135032">size</a>();
450
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c < charsetsize; ++c) {
451
<span class="comment">// We always add a shape for each character to keep the index in sync</span>
452
<span class="comment">// with the unichar_id.</span>
453
<span class="keywordtype">int</span> shape_id = owned_shape_table_-><a class="code" href="a00544.html#a4560e30f0df9126da3462e4858e6a2db">AddShape</a>(c, 0);
454
<span class="keywordflow">for</span> (<span class="keywordtype">int</span> f = 1; f < num_fonts; ++f) {
455
<span class="keywordflow">if</span> (sample_set_-><a class="code" href="a00631.html#a7f5168960275b7cfed23408acd78d275">NumClassSamples</a>(f, c, <span class="keyword">true</span>) > 0) {
456
owned_shape_table_-><a class="code" href="a00544.html#ac8c09a4d3aefed5026a4837f514a3c14">AddToShape</a>(shape_id, c, f);
460
shape_table_ = owned_shape_table_;
462
<span class="keywordflow">if</span> (shape_table_ != NULL) {
463
num_shapes_ = shape_table_-><a class="code" href="a00544.html#a924919daeadb48539e3d68c65013c173">NumShapes</a>();
464
} <span class="keywordflow">else</span> {
465
num_shapes_ = randomize ? sample_set_-><a class="code" href="a00631.html#a6d2560a4ae24102d9919eb961d0bca34">num_samples</a>()
466
: sample_set_-><a class="code" href="a00631.html#af48888d68fc56c5b6911957530b59389">num_raw_samples</a>();
468
<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>();
473
<a class="anchor" id="a476d245234d73a6c9ef7c85b57148a27"></a><!-- doxytag: member="tesseract::SampleIterator::MapSampleFeatures" ref="a476d245234d73a6c9ef7c85b57148a27" args="(const IntFeatureMap &feature_map)" -->
474
<div class="memitem">
475
<div class="memproto">
476
<table class="memname">
478
<td class="memname">void <a class="el" href="a00526.html#a476d245234d73a6c9ef7c85b57148a27">tesseract::SampleIterator::MapSampleFeatures</a> </td>
480
<td class="paramtype">const <a class="el" href="a00429.html">IntFeatureMap</a> & </td>
481
<td class="paramname"><em>feature_map</em></td><td>)</td>
488
<p>Definition at line <a class="el" href="a00936_source.html#l00211">211</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
489
<div class="fragment"><pre class="fragment"> {
490
<span class="keywordflow">for</span> (<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>(); !<a class="code" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">AtEnd</a>(); <a class="code" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a>()) {
491
TrainingSample* <a class="code" href="a00525.html">sample</a> = <a class="code" href="a00526.html#a0941312fec55859dc29a1b32b0e298cd">MutableSample</a>();
492
sample->MapFeatures(feature_map);
498
<a class="anchor" id="a0941312fec55859dc29a1b32b0e298cd"></a><!-- doxytag: member="tesseract::SampleIterator::MutableSample" ref="a0941312fec55859dc29a1b32b0e298cd" args="() const " -->
499
<div class="memitem">
500
<div class="memproto">
501
<table class="memname">
503
<td class="memname"><a class="el" href="a00630.html">TrainingSample</a> * <a class="el" href="a00526.html#a0941312fec55859dc29a1b32b0e298cd">tesseract::SampleIterator::MutableSample</a> </td>
505
<td class="paramname"></td><td>)</td>
512
<p>Definition at line <a class="el" href="a00936_source.html#l00114">114</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
513
<div class="fragment"><pre class="fragment"> {
514
<span class="keywordflow">if</span> (shape_table_ != NULL) {
515
<span class="keyword">const</span> UnicharAndFonts* shape_entry = GetShapeEntry();
516
<span class="keywordtype">int</span> char_id = shape_entry->unichar_id;
517
<span class="keywordtype">int</span> font_id = shape_entry->font_ids[shape_font_index_];
518
<span class="keywordflow">return</span> sample_set_-><a class="code" href="a00631.html#af960a1e74b485c6f7d0baad12c93a925">MutableSample</a>(font_id, char_id, sample_index_);
519
} <span class="keywordflow">else</span> {
520
<span class="keywordflow">return</span> sample_set_-><a class="code" href="a00631.html#ad753995a898fee6ac9ad58b7af4ffc7e">mutable_sample</a>(shape_index_);
526
<a class="anchor" id="aea58e8234a0b6bab9061929622150bb1"></a><!-- doxytag: member="tesseract::SampleIterator::Next" ref="aea58e8234a0b6bab9061929622150bb1" args="()" -->
527
<div class="memitem">
528
<div class="memproto">
529
<table class="memname">
531
<td class="memname">void <a class="el" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">tesseract::SampleIterator::Next</a> </td>
533
<td class="paramname"></td><td>)</td>
540
<p>Definition at line <a class="el" href="a00936_source.html#l00156">156</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
541
<div class="fragment"><pre class="fragment"> {
542
<span class="keywordflow">if</span> (shape_table_ != NULL) {
543
<span class="comment">// Next sample in this class/font combination.</span>
545
<span class="keywordflow">if</span> (sample_index_ < num_samples_)
546
<span class="keywordflow">return</span>;
547
<span class="comment">// Next font in this class in this shape.</span>
549
<span class="keywordflow">do</span> {
551
<span class="keywordflow">if</span> (shape_font_index_ >= num_shape_fonts_) {
552
<span class="comment">// Next unichar in this shape.</span>
553
shape_font_index_ = 0;
555
<span class="keywordflow">if</span> (shape_char_index_ >= num_shape_chars_) {
556
<span class="comment">// Find the next shape that is mapped in the charset_map_.</span>
557
shape_char_index_ = 0;
558
<span class="keywordflow">do</span> {
560
} <span class="keywordflow">while</span> (shape_index_ < num_shapes_ &&
561
charset_map_ != NULL &&
562
charset_map_-><a class="code" href="a00416.html#a2c0f96f5d5fad6c9973e1b074fac5a03">SparseToCompact</a>(shape_index_) < 0);
563
<span class="keywordflow">if</span> (shape_index_ >= num_shapes_)
564
<span class="keywordflow">return</span>; <span class="comment">// The end.</span>
565
num_shape_chars_ = shape_table_-><a class="code" href="a00544.html#a9334161c64756c591ff7d4fca22277f5">GetShape</a>(shape_index_).<a class="code" href="a00539.html#a0fca7f64992c74492787d00240a22913">size</a>();
568
<span class="keyword">const</span> UnicharAndFonts* shape_entry = GetShapeEntry();
569
num_shape_fonts_ = shape_entry->font_ids.size();
570
<span class="keywordtype">int</span> char_id = shape_entry->unichar_id;
571
<span class="keywordtype">int</span> font_id = shape_entry->font_ids[shape_font_index_];
572
num_samples_ = sample_set_-><a class="code" href="a00631.html#a7f5168960275b7cfed23408acd78d275">NumClassSamples</a>(font_id, char_id, randomize_);
573
} <span class="keywordflow">while</span> (num_samples_ == 0);
574
} <span class="keywordflow">else</span> {
575
<span class="comment">// We are just iterating over the samples.</span>
582
<a class="anchor" id="ac0a70c42261385f21d97c699ff181fad"></a><!-- doxytag: member="tesseract::SampleIterator::NormalizeSamples" ref="ac0a70c42261385f21d97c699ff181fad" args="()" -->
583
<div class="memitem">
584
<div class="memproto">
585
<table class="memname">
587
<td class="memname">double <a class="el" href="a00526.html#ac0a70c42261385f21d97c699ff181fad">tesseract::SampleIterator::NormalizeSamples</a> </td>
589
<td class="paramname"></td><td>)</td>
596
<p>Definition at line <a class="el" href="a00936_source.html#l00233">233</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
597
<div class="fragment"><pre class="fragment"> {
598
<span class="keywordtype">double</span> total_weight = 0.0;
599
<span class="keywordtype">int</span> sample_count = 0;
600
<span class="keywordflow">for</span> (<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>(); !<a class="code" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">AtEnd</a>(); <a class="code" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a>()) {
601
<span class="keyword">const</span> TrainingSample& <a class="code" href="a00525.html">sample</a> = <a class="code" href="a00526.html#a274fa0bca10b58d7efddebde0338a698">GetSample</a>();
602
total_weight += sample.weight();
605
<span class="comment">// Normalize samples.</span>
606
<span class="keywordtype">double</span> min_assigned_sample_weight = 1.0;
607
<span class="keywordflow">if</span> (total_weight > 0.0) {
608
<span class="keywordflow">for</span> (<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>(); !<a class="code" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">AtEnd</a>(); <a class="code" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a>()) {
609
TrainingSample* sample = <a class="code" href="a00526.html#a0941312fec55859dc29a1b32b0e298cd">MutableSample</a>();
610
<span class="keywordtype">double</span> weight = sample->weight() / total_weight;
611
<span class="keywordflow">if</span> (weight < min_assigned_sample_weight)
612
min_assigned_sample_weight = weight;
613
sample->set_weight(weight);
616
<span class="keywordflow">return</span> min_assigned_sample_weight;
621
<a class="anchor" id="a11e0a8f5f60216b68c3fe6528d551295"></a><!-- doxytag: member="tesseract::SampleIterator::sample_set" ref="a11e0a8f5f60216b68c3fe6528d551295" args="() const " -->
622
<div class="memitem">
623
<div class="memproto">
624
<table class="memname">
626
<td class="memname">const <a class="el" href="a00631.html">TrainingSampleSet</a>* <a class="el" href="a00526.html#a11e0a8f5f60216b68c3fe6528d551295">tesseract::SampleIterator::sample_set</a> </td>
628
<td class="paramname"></td><td>)</td>
629
<td> const<code> [inline]</code></td>
635
<p>Definition at line <a class="el" href="a00937_source.html#l00144">144</a> of file <a class="el" href="a00937_source.html">sampleiterator.h</a>.</p>
636
<div class="fragment"><pre class="fragment"> {
637
<span class="keywordflow">return</span> sample_set_;
642
<a class="anchor" id="aeae6fe3f5607f0e0ff9f82151d096ced"></a><!-- doxytag: member="tesseract::SampleIterator::shape_table" ref="aeae6fe3f5607f0e0ff9f82151d096ced" args="() const " -->
643
<div class="memitem">
644
<div class="memproto">
645
<table class="memname">
647
<td class="memname">const <a class="el" href="a00544.html">ShapeTable</a>* <a class="el" href="a00526.html#aeae6fe3f5607f0e0ff9f82151d096ced">tesseract::SampleIterator::shape_table</a> </td>
649
<td class="paramname"></td><td>)</td>
650
<td> const<code> [inline]</code></td>
656
<p>Definition at line <a class="el" href="a00937_source.html#l00140">140</a> of file <a class="el" href="a00937_source.html">sampleiterator.h</a>.</p>
657
<div class="fragment"><pre class="fragment"> {
658
<span class="keywordflow">return</span> shape_table_;
663
<a class="anchor" id="ad575eda15498de5a5de614dbcfa4d0aa"></a><!-- doxytag: member="tesseract::SampleIterator::SparseCharsetSize" ref="ad575eda15498de5a5de614dbcfa4d0aa" args="() const " -->
664
<div class="memitem">
665
<div class="memproto">
666
<table class="memname">
668
<td class="memname">int <a class="el" href="a00526.html#ad575eda15498de5a5de614dbcfa4d0aa">tesseract::SampleIterator::SparseCharsetSize</a> </td>
670
<td class="paramname"></td><td>)</td>
677
<p>Definition at line <a class="el" href="a00936_source.html#l00202">202</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
678
<div class="fragment"><pre class="fragment"> {
679
<span class="keywordflow">return</span> charset_map_ != NULL
680
? charset_map_-><a class="code" href="a00416.html#ae108e47d0f0049137072ad2bc1f6705d">SparseSize</a>()
681
: (shape_table_ != NULL ? shape_table_-><a class="code" href="a00544.html#a924919daeadb48539e3d68c65013c173">NumShapes</a>()
682
: sample_set_-><a class="code" href="a00631.html#a4c13c167bc217d3e2e519d746764de49">charsetsize</a>());
687
<a class="anchor" id="a82e48b99ecac34b9e0dbf8a96521bb4e"></a><!-- doxytag: member="tesseract::SampleIterator::UniformSamples" ref="a82e48b99ecac34b9e0dbf8a96521bb4e" args="()" -->
688
<div class="memitem">
689
<div class="memproto">
690
<table class="memname">
692
<td class="memname">int <a class="el" href="a00526.html#a82e48b99ecac34b9e0dbf8a96521bb4e">tesseract::SampleIterator::UniformSamples</a> </td>
694
<td class="paramname"></td><td>)</td>
701
<p>Definition at line <a class="el" href="a00936_source.html#l00220">220</a> of file <a class="el" href="a00936_source.html">sampleiterator.cpp</a>.</p>
702
<div class="fragment"><pre class="fragment"> {
703
<span class="keywordtype">int</span> num_good_samples = 0;
704
<span class="keywordflow">for</span> (<a class="code" href="a00526.html#a90e5190efbff41c67519ba29fa59186f">Begin</a>(); !<a class="code" href="a00526.html#a4dde9bf911b04c848fbdc4cca8699b70">AtEnd</a>(); <a class="code" href="a00526.html#aea58e8234a0b6bab9061929622150bb1">Next</a>()) {
705
TrainingSample* <a class="code" href="a00525.html">sample</a> = <a class="code" href="a00526.html#a0941312fec55859dc29a1b32b0e298cd">MutableSample</a>();
706
sample->set_weight(1.0);
709
<a class="code" href="a00526.html#ac0a70c42261385f21d97c699ff181fad">NormalizeSamples</a>();
710
<span class="keywordflow">return</span> num_good_samples;
715
<hr/>The documentation for this class was generated from the following files:<ul>
716
<li>/usr/local/google/home/jbreiden/tesseract-ocr-read-only/classify/<a class="el" href="a00937_source.html">sampleiterator.h</a></li>
717
<li>/usr/local/google/home/jbreiden/tesseract-ocr-read-only/classify/<a class="el" href="a00936_source.html">sampleiterator.cpp</a></li>
719
</div><!-- contents -->
721
<!-- window showing the filter options -->
722
<div id="MSearchSelectWindow"
723
onmouseover="return searchBox.OnSearchSelectShow()"
724
onmouseout="return searchBox.OnSearchSelectHide()"
725
onkeydown="return searchBox.OnSearchSelectKey(event)">
726
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div>
728
<!-- iframe showing the search results (closed by default) -->
729
<div id="MSearchResultsWindow">
730
<iframe src="javascript:void(0)" frameborder="0"
731
name="MSearchResults" id="MSearchResults">
735
<div id="nav-path" class="navpath">
737
<li class="navelem"><a class="el" href="a01265.html">tesseract</a> </li>
738
<li class="navelem"><a class="el" href="a00526.html">SampleIterator</a> </li>
740
<li class="footer">Generated on Mon Feb 3 2014 10:59:21 for tesseract by
741
<a href="http://www.doxygen.org/index.html">
742
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>