|
|
|
@ -528,6 +528,7 @@ cvSubstituteContour( CvContourScanner scanner, CvSeq * new_contour ) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const int MAX_SIZE = 16; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
marks domain border with +/-<constant> and stores the contour into CvSeq. |
|
|
|
@ -544,7 +545,7 @@ icvFetchContour( schar *ptr, |
|
|
|
|
int _method ) |
|
|
|
|
{ |
|
|
|
|
const schar nbd = 2; |
|
|
|
|
int deltas[16]; |
|
|
|
|
int deltas[MAX_SIZE]; |
|
|
|
|
CvSeqWriter writer; |
|
|
|
|
schar *i0 = ptr, *i1, *i3, *i4 = 0; |
|
|
|
|
int prev_s = -1, s, s_end; |
|
|
|
@ -588,8 +589,9 @@ icvFetchContour( schar *ptr, |
|
|
|
|
for( ;; ) |
|
|
|
|
{ |
|
|
|
|
s_end = s; |
|
|
|
|
s = std::min(s, MAX_SIZE - 1); |
|
|
|
|
|
|
|
|
|
for( ;; ) |
|
|
|
|
while( s < MAX_SIZE - 1 ) |
|
|
|
|
{ |
|
|
|
|
i4 = i3 + deltas[++s]; |
|
|
|
|
if( *i4 != 0 ) |
|
|
|
@ -654,8 +656,8 @@ icvFetchContour( schar *ptr, |
|
|
|
|
static int |
|
|
|
|
icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole ) |
|
|
|
|
{ |
|
|
|
|
int deltas[16]; |
|
|
|
|
schar *i0 = ptr, *i1, *i3, *i4; |
|
|
|
|
int deltas[MAX_SIZE]; |
|
|
|
|
schar *i0 = ptr, *i1, *i3, *i4 = NULL; |
|
|
|
|
int s, s_end; |
|
|
|
|
|
|
|
|
|
/* initialize local state */ |
|
|
|
@ -682,7 +684,8 @@ icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole ) |
|
|
|
|
for( ;; ) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
for( ;; ) |
|
|
|
|
s = std::min(s, MAX_SIZE - 1); |
|
|
|
|
while( s < MAX_SIZE - 1 ) |
|
|
|
|
{ |
|
|
|
|
i4 = i3 + deltas[++s]; |
|
|
|
|
if( *i4 != 0 ) |
|
|
|
@ -709,9 +712,9 @@ icvFetchContourEx( schar* ptr, |
|
|
|
|
int nbd, |
|
|
|
|
CvRect* _rect ) |
|
|
|
|
{ |
|
|
|
|
int deltas[16]; |
|
|
|
|
int deltas[MAX_SIZE]; |
|
|
|
|
CvSeqWriter writer; |
|
|
|
|
schar *i0 = ptr, *i1, *i3, *i4; |
|
|
|
|
schar *i0 = ptr, *i1, *i3, *i4 = NULL; |
|
|
|
|
CvRect rect; |
|
|
|
|
int prev_s = -1, s, s_end; |
|
|
|
|
int method = _method - 1; |
|
|
|
@ -759,8 +762,9 @@ icvFetchContourEx( schar* ptr, |
|
|
|
|
for( ;; ) |
|
|
|
|
{ |
|
|
|
|
s_end = s; |
|
|
|
|
s = std::min(s, MAX_SIZE - 1); |
|
|
|
|
|
|
|
|
|
for( ;; ) |
|
|
|
|
while( s < MAX_SIZE - 1 ) |
|
|
|
|
{ |
|
|
|
|
i4 = i3 + deltas[++s]; |
|
|
|
|
if( *i4 != 0 ) |
|
|
|
@ -833,8 +837,8 @@ icvFetchContourEx( schar* ptr, |
|
|
|
|
static int |
|
|
|
|
icvTraceContour_32s( int *ptr, int step, int *stop_ptr, int is_hole ) |
|
|
|
|
{ |
|
|
|
|
int deltas[16]; |
|
|
|
|
int *i0 = ptr, *i1, *i3, *i4; |
|
|
|
|
int deltas[MAX_SIZE]; |
|
|
|
|
int *i0 = ptr, *i1, *i3, *i4 = NULL; |
|
|
|
|
int s, s_end; |
|
|
|
|
const int right_flag = INT_MIN; |
|
|
|
|
const int new_flag = (int)((unsigned)INT_MIN >> 1); |
|
|
|
@ -863,8 +867,9 @@ icvTraceContour_32s( int *ptr, int step, int *stop_ptr, int is_hole ) |
|
|
|
|
for( ;; ) |
|
|
|
|
{ |
|
|
|
|
s_end = s; |
|
|
|
|
s = std::min(s, MAX_SIZE - 1); |
|
|
|
|
|
|
|
|
|
for( ;; ) |
|
|
|
|
while( s < MAX_SIZE - 1 ) |
|
|
|
|
{ |
|
|
|
|
i4 = i3 + deltas[++s]; |
|
|
|
|
if( (*i4 & value_mask) == ccomp_val ) |
|
|
|
@ -890,7 +895,7 @@ icvFetchContourEx_32s( int* ptr, |
|
|
|
|
int _method, |
|
|
|
|
CvRect* _rect ) |
|
|
|
|
{ |
|
|
|
|
int deltas[16]; |
|
|
|
|
int deltas[MAX_SIZE]; |
|
|
|
|
CvSeqWriter writer; |
|
|
|
|
int *i0 = ptr, *i1, *i3, *i4; |
|
|
|
|
CvRect rect; |
|
|
|
@ -925,7 +930,7 @@ icvFetchContourEx_32s( int* ptr, |
|
|
|
|
s = (s - 1) & 7; |
|
|
|
|
i1 = i0 + deltas[s]; |
|
|
|
|
} |
|
|
|
|
while( (*i1 & value_mask) != ccomp_val && s != s_end ); |
|
|
|
|
while( (*i1 & value_mask) != ccomp_val && s != s_end && ( s < MAX_SIZE - 1 ) ); |
|
|
|
|
|
|
|
|
|
if( s == s_end ) /* single pixel domain */ |
|
|
|
|
{ |
|
|
|
@ -945,12 +950,11 @@ icvFetchContourEx_32s( int* ptr, |
|
|
|
|
{ |
|
|
|
|
s_end = s; |
|
|
|
|
|
|
|
|
|
for( ;; ) |
|
|
|
|
do |
|
|
|
|
{ |
|
|
|
|
i4 = i3 + deltas[++s]; |
|
|
|
|
if( (*i4 & value_mask) == ccomp_val ) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
while( (*i4 & value_mask) != ccomp_val && ( s < MAX_SIZE - 1 ) ); |
|
|
|
|
s &= 7; |
|
|
|
|
|
|
|
|
|
/* check "right" bound */ |
|
|
|
|