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

Function cvConvexityDefects

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

contour must be a simple polygon */ it must have more than 3 points */

Source from the content-addressed store, hash-verified

498/* contour must be a simple polygon */
499/* it must have more than 3 points */
500CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
501 const CvArr* hullarray,
502 CvMemStorage* storage )
503{
504 CvSeq* defects = 0;
505
506 int i, index;
507 CvPoint* hull_cur;
508
509 /* is orientation of hull different from contour one */
510 int rev_orientation;
511
512 CvContour contour_header;
513 union { CvContour c; CvSeq s; } hull_header;
514 CvSeqBlock block, hullblock;
515 CvSeq *ptseq = (CvSeq*)array, *hull = (CvSeq*)hullarray;
516
517 CvSeqReader hull_reader;
518 CvSeqReader ptseq_reader;
519 CvSeqWriter writer;
520 int is_index;
521
522 if( CV_IS_SEQ( ptseq ))
523 {
524 if( !CV_IS_SEQ_POINT_SET( ptseq ))
525 CV_Error( CV_StsUnsupportedFormat,
526 "Input sequence is not a sequence of points" );
527 if( !storage )
528 storage = ptseq->storage;
529 }
530 else
531 {
532 ptseq = cvPointSeqFromMat( CV_SEQ_KIND_GENERIC, array, &contour_header, &block );
533 }
534
535 if( CV_SEQ_ELTYPE( ptseq ) != CV_32SC2 )
536 CV_Error( CV_StsUnsupportedFormat, "Floating-point coordinates are not supported here" );
537
538 if( CV_IS_SEQ( hull ))
539 {
540 int hulltype = CV_SEQ_ELTYPE( hull );
541 if( hulltype != CV_SEQ_ELTYPE_PPOINT && hulltype != CV_SEQ_ELTYPE_INDEX )
542 CV_Error( CV_StsUnsupportedFormat,
543 "Convex hull must represented as a sequence "
544 "of indices or sequence of pointers" );
545 if( !storage )
546 storage = hull->storage;
547 }
548 else
549 {
550 CvMat* mat = (CvMat*)hull;
551
552 if( !CV_IS_MAT( hull ))
553 CV_Error(CV_StsBadArg, "Convex hull is neither sequence nor matrix");
554
555 if( (mat->cols != 1 && mat->rows != 1) ||
556 !CV_IS_MAT_CONT(mat->type) || CV_MAT_TYPE(mat->type) != CV_32SC1 )
557 CV_Error( CV_StsBadArg,

Callers 1

convexityDefectsMethod · 0.85

Calls 9

cvPointSeqFromMatFunction · 0.85
cvMakeSeqHeaderForArrayFunction · 0.85
cvCreateSeqFunction · 0.85
cvSeqElemIdxFunction · 0.85
cvStartReadSeqFunction · 0.85
cvSetSeqReaderPosFunction · 0.85
cvStartAppendToSeqFunction · 0.85
sqrtFunction · 0.85
cvEndWriteSeqFunction · 0.85

Tested by

no test coverage detected