MCPcopy Create free account
hub / github.com/creatale/node-dv / icvFetchContour

Function icvFetchContour

deps/opencv/modules/imgproc/src/contours.cpp:500–609  ·  view source on GitHub ↗

marks domain border with +/- and stores the contour into CvSeq. method: <0 - chain ==0 - direct >0 - simple approximation */

Source from the content-addressed store, hash-verified

498 >0 - simple approximation
499*/
500static void
501icvFetchContour( schar *ptr,
502 int step,
503 CvPoint pt,
504 CvSeq* contour,
505 int _method )
506{
507 const schar nbd = 2;
508 int deltas[16];
509 CvSeqWriter writer;
510 schar *i0 = ptr, *i1, *i3, *i4 = 0;
511 int prev_s = -1, s, s_end;
512 int method = _method - 1;
513
514 assert( (unsigned) _method <= CV_CHAIN_APPROX_SIMPLE );
515
516 /* initialize local state */
517 CV_INIT_3X3_DELTAS( deltas, step, 1 );
518 memcpy( deltas + 8, deltas, 8 * sizeof( deltas[0] ));
519
520 /* initialize writer */
521 cvStartAppendToSeq( contour, &writer );
522
523 if( method < 0 )
524 ((CvChain *) contour)->origin = pt;
525
526 s_end = s = CV_IS_SEQ_HOLE( contour ) ? 0 : 4;
527
528 do
529 {
530 s = (s - 1) & 7;
531 i1 = i0 + deltas[s];
532 if( *i1 != 0 )
533 break;
534 }
535 while( s != s_end );
536
537 if( s == s_end ) /* single pixel domain */
538 {
539 *i0 = (schar) (nbd | -128);
540 if( method >= 0 )
541 {
542 CV_WRITE_SEQ_ELEM( pt, writer );
543 }
544 }
545 else
546 {
547 i3 = i0;
548 prev_s = s ^ 4;
549
550 /* follow border */
551 for( ;; )
552 {
553 s_end = s;
554
555 for( ;; )
556 {
557 i4 = i3 + deltas[++s];

Callers 1

cvFindNextContourFunction · 0.85

Calls 3

cvStartAppendToSeqFunction · 0.85
cvEndWriteSeqFunction · 0.85
cvBoundingRectFunction · 0.85

Tested by

no test coverage detected