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

Method convexityDefects

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

Source from the content-addressed store, hash-verified

1968
1969
1970void cv::convexityDefects( InputArray _points, InputArray _hull, OutputArray _defects )
1971{
1972 Mat points = _points.getMat();
1973 int ptnum = points.checkVector(2, CV_32S);
1974 CV_Assert( ptnum > 3 );
1975 Mat hull = _hull.getMat();
1976 CV_Assert( hull.checkVector(1, CV_32S) > 2 );
1977 Ptr<CvMemStorage> storage = cvCreateMemStorage();
1978
1979 CvMat c_points = points, c_hull = hull;
1980 CvSeq* seq = cvConvexityDefects(&c_points, &c_hull, storage);
1981 int i, n = seq->total;
1982
1983 if( n == 0 )
1984 {
1985 _defects.release();
1986 return;
1987 }
1988
1989 _defects.create(n, 1, CV_32SC4);
1990 Mat defects = _defects.getMat();
1991
1992 SeqIterator<CvConvexityDefect> it = Seq<CvConvexityDefect>(seq).begin();
1993 CvPoint* ptorg = (CvPoint*)points.data;
1994
1995 for( i = 0; i < n; i++, ++it )
1996 {
1997 CvConvexityDefect& d = *it;
1998 int idx0 = (int)(d.start - ptorg);
1999 int idx1 = (int)(d.end - ptorg);
2000 int idx2 = (int)(d.depth_point - ptorg);
2001 CV_Assert( 0 <= idx0 && idx0 < ptnum );
2002 CV_Assert( 0 <= idx1 && idx1 < ptnum );
2003 CV_Assert( 0 <= idx2 && idx2 < ptnum );
2004 CV_Assert( d.depth >= 0 );
2005 int idepth = cvRound(d.depth*256);
2006 defects.at<Vec4i>(i) = Vec4i(idx0, idx1, idx2, idepth);
2007 }
2008}
2009
2010
2011bool cv::isContourConvex( InputArray _contour )

Callers

nothing calls this directly

Calls 7

cvConvexityDefectsFunction · 0.85
cvRoundFunction · 0.85
checkVectorMethod · 0.80
getMatMethod · 0.45
releaseMethod · 0.45
createMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected