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
#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 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,
* \brief Returns the assigned maximal width for fast tracks.
inline int fastTracksMaxWidth () const { return imaxWidth; }
* \brief Sets the assigned maximal width for fast tracks.
inline void setFastTracksMaxWidth (int value) {
if (value > 0) imaxWidth = value; }
* \brief Returns the assigned maximal width for fine tracks.
inline int fineTracksMaxWidth () const { return fmaxWidth; }
/**
* \brief Sets the assigned maximal width for fine tracks.
*/
inline void setFineTracksMaxWidth (int value) {
if (value > 0) fmaxWidth = value; }
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
/**
* \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 vicinity threshold used for fast tracking.
inline int getVicinityThreshold () { return vicinityThreshold; }
/**
* \brief Increments the vicinity threshold used for fast tracking.
* @param inc Increment value.
*/
inline void incVicinityThreshold (int inc) {
if (vicinityThreshold < NO_VICINITY) {
vicinityThreshold += inc;
if (vicinityThreshold < 1) vicinityThreshold = 1; } }
/**
* \brief Returns the vicinity test status.
*/
inline bool vicinityConstraintOn () {
return (vicinityThreshold < NO_VICINITY); }
/**
* \brief Switches the vicinity test used for fast tracking.
*/
inline void switchVicinityConstraint () {
vicinityThreshold += (vicinityThreshold > NO_VICINITY ?
- NO_VICINITY : NO_VICINITY); }
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
/**
* \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 max segment width for fast tracks. */
static const int DEFAULT_FAST_TRACK_MAX_WIDTH;
/** Default value for the max segment width for fine tracks. */
static const int DEFAULT_FINE_TRACK_MAX_WIDTH;
/** Default value for the accepted number of successive lacks. */
/** Default value for the vicinity test used for fast tracking. */
static const int DEFAULT_VICINITY_THRESHOLD;
/** Large value to release the vicinity constraint. */
static const int NO_VICINITY;
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
/** 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;
/** Scanned map left bound. */
int xmin;
/** Scanned map lower bound. */
int ymin;
/** Scanned map width. */
int width;
/** Scanned map height. */
int height;
/** Blurred segment max width for fast tracks. */
int imaxWidth;
/** Blurred segment max width for fine tracks. */
int fmaxWidth;
/** Number of awaited points after each failure. */
int minRestart;
/** Accepted number of successive lacks (wrt restart points). */
int acceptedLacks;
/** Vicinity threshold used for fast tracking. */
int vicinityThreshold;
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/** 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