Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#ifndef BLURRED_SEGMENT_TRACKER_H
#define BLURRED_SEGMENT_TRACKER_H
#include <vector>
#include "scannerprovider.h"
#include "blurredsegment.h"
#include "vmap.h"
using namespace std;
/**
* @class BSTracker bstracker.h
* \brief Blurred segment tracker in grey level images.
* \author {P. Even and B. Kerautret}
*/
class BSTracker
{
public:
/**
* \brief Creates a blurred segment tracker.
*/
BSTracker ();
/**
* \brief Deletes the blurred segment tracker.
*/
~BSTracker ();
/**
* \brief Clears off stored information.
*/
void clear ();
/**
* \brief Builds and returns a blurred segment from only gradient maximum.
* @param p1 Initial stroke start point.
* @param p2 Initial stroke end point.
* @param p0 Initial segment start point (if different from NULL).
*/
BlurredSegment *fastTrack (const Pt2i &p1, const Pt2i &p2,
Pt2i *p0 = NULL);
/**
* \brief Builds and returns a blurred segment from local gradient maxima.
* Finer detection using gradient ridges and direction input.
* @param center Central point of the scan.
* @param scandir Scan direction
* @param scanwidth2 Half width of the scan strip.
* @param bswidth Initial maximal width of the blurred segment to build.
* @param gref Gradient vector reference to select candidates.
*/
BlurredSegment *fineTrack (const Pt2i ¢er, const Vr2i &scandir,
int scanwidth2, int bswidth,
const Vr2i &gref);
/**
* \brief Returns the input maximal width of the blurred segment.
*/
inline int inputMaxWidth () const { return maxWidth; }
/**
* \brief Sets the input maximal width of the blurred segment.
*/
inline void setInputMaxWidth (int value) {
if (value > 0) maxWidth = value; }
/**
* \brief Returns the default minimal length of scan lines.
*/
inline int defaultMinScan () const { return MIN_SCAN; }
/**
* \brief Returns the pixel lack tolerence for exdending the blurred segment..
*/
inline int pixelLackTolerence () const { return acceptedLacks; }
/**
* \brief Sets the pixel lack tolerence for extending the blurred segment.
*/
inline void setPixelLackTolerence (int number)
{
if (number >= 0)
{
acceptedLacks = number;
if (minRestart != 1) minRestart = number;
}
}
/**
* \brief Returns the count of accepted points to release a failure.
*/
inline int getRestartOnLack () { return minRestart; }
/**
* \brief Switches on or off the automatic restart after failure.
*/
inline void switchAutoRestart ()
{
minRestart = (minRestart == 1 ? acceptedLacks : 1);
}
/**
* \brief Sets the image data.
*/
void setGradientMap (VMap *data);
/**
* \brief Returns the proximity threshold.
*/
inline int proximityThreshold () { return proxThreshold; }
/**
* \brief Returns if the dynamic scans are used.
*/
inline bool dynamicScansOn () { return dynamicScans; }
/**
* \brief Returns the upper bound of the final scan.
*/
inline vector<Pt2i> getScanBound1 () const { return scanBound1; }
/**
* \brief Returns the lower bound of the final scan.
*/
inline vector<Pt2i> getScanBound2 () const { return scanBound2; }
/**
* \brief Returns the scan lines.
*/
inline vector <vector <Pt2i> > getScans () const { return scanLine; }
/**
* \brief Returns whether the scan record modality is set.
*/
inline bool scanRecordOn () { return recordScans; }
/**
* \brief Sets the scan record modality.
* @param status Sets on if true, off otherwise.
*/
inline void setScanRecord (bool status) { recordScans = status; }
/**
* \brief Toggles the dynamic scans use.
*/
inline void toggleDynamicScans () { dynamicScans = ! dynamicScans; }
/**
* \brief Switches the scan extent limitation..
*/
void switchScanExtent ();
/**
* \brief Returns the scan extent limit.
*/
inline int maxScanExtent () { return (maxScan); }
/**
* \brief Sets the dynamic scans on or off.
*/
inline void setDynamicScans (bool onOff) { dynamicScans = onOff; }
/**
* \brief Returns if the thinning is activated.
*/
inline bool isThinningActivated () { return thinningOn; }
/**
* \brief Toggles the thinning strategy.
*/
inline void toggleThinning () { thinningOn = ! thinningOn; }
/**
* \brief Switches on or off the orthogonal scanning modality.
*/
void switchOrthoScans ();
/**
* \brief Switches on or off the orthogonal scanning modality.
*/
inline bool orthoScansOn () { return orthoScan; }
private :
// Segment detection default parameters.
/** Default value for the initial max segment width. */
static const int DEFAULT_MAX_WIDTH;
/** Default value forr the accepted number of successive lacks. */
static const int DEFAULT_ACCEPTED_LACKS;
/** Default value for the proximity threshold used for fast tracking. */
static const int DEFAULT_PROXIMITY_THRESHOLD;
/** Minimal length of scan length to be processed. */
static const int MIN_SCAN;
/** Default value for the maximal number of scans processed on each side. */
static const int DEFAULT_MAX_SCAN;
// Dynamical scan default parameters.
/* Count of points before activating the fitting on the detected segment. */
static const int DEFAULT_FITTING_DELAY;
// Width thinning default parameters.
/* Count of points before activating the width thinning. */
static const int DEFAULT_THINNING_DELAY;
/** Value which controls the width thinning speed.
* It is the percentage of width offset withdrawn from the width tolerence.
* Width offset = width tolerence - blurred segment width. */
static const int DEFAULT_THINNING_SPEED;
/** Minimal value of the percentage of width offset wrt segment width. */
static const int DEFAULT_THINNING_REACH;
/** Resolution of the max segment width when thinning. */
static const int DEFAULT_THINNING_RESOLUTION;
/** Segment stop information : no start point found. */
static const int FAILURE_NO_START;
/** Segment stop information : image bound reached on the right. */
static const int FAILURE_IMAGE_BOUND_ON_RIGHT;
/** Segment stop information : image bound reached on the left. */
static const int FAILURE_IMAGE_BOUND_ON_LEFT;
/** Segment stop information : lost orientation at dynamical reset start. */
static const int FAILURE_LOST_ORIENTATION;
/** Blurred segment max half-width. */
int maxWidth;
/** Number of awaited points after each failure. */
int minRestart;
/** Accepted number of successive lacks (wrt restart points). */
int acceptedLacks;
/** Proximity threshold used for fast tracking. */
int proxThreshold;
/** Orthogonal scanning modality status */
bool orthoScan;
/** Kind of scans used : dynamic if true. */
bool dynamicScans;
/** Minimal detection width before activating the dynamical scans. */
int fittingDelay;
/** Segment thinning strategy. */
bool thinningOn;
/** Width thinning delay. */
int thinningDelay;
/** Width thinning speed : amount of thinning offset withdrawn. */
AbsRat thinningSpeed;
/** Minimal control width wrt detected segment width when thinning. */
AbsRat thinningReach;
/** Gradient map. */
VMap *gMap;
/** Maximum number of scans. */
int maxScan;
/** Failure cause. */
int fail;
/** Candidates array for internal use. */
int *cand;
/** Index of the last successful scan on right side. */
int rscan;
/** Index of the last successful scan on left side. */
int lscan;
/** Directional scanner provider.
* Automatically selects the appropriate octant. */
ScannerProvider scanp;
/** Upper bound of the scan. */
vector<Pt2i> scanBound1;
/** Lower bound of the scan. */
vector<Pt2i> scanBound2;
/** Scan lines. */
vector <vector <Pt2i> > scanLine;
/** Dynamical scanner record modality. */
bool recordScans;
};
#endif