| 1968 | |
| 1969 | |
| 1970 | void 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 | |
| 2011 | bool cv::isContourConvex( InputArray _contour ) |
nothing calls this directly
no test coverage detected