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

Function cvCheckContourConvexity

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

Source from the content-addressed store, hash-verified

699
700
701CV_IMPL int
702cvCheckContourConvexity( const CvArr* array )
703{
704 int flag = -1;
705
706 int i;
707 int orientation = 0;
708 CvSeqReader reader;
709 CvContour contour_header;
710 CvSeqBlock block;
711 CvSeq* contour = (CvSeq*)array;
712
713 if( CV_IS_SEQ(contour) )
714 {
715 if( !CV_IS_SEQ_POINT_SET(contour))
716 CV_Error( CV_StsUnsupportedFormat,
717 "Input sequence must be polygon (closed 2d curve)" );
718 }
719 else
720 {
721 contour = cvPointSeqFromMat(CV_SEQ_KIND_CURVE|CV_SEQ_FLAG_CLOSED, array, &contour_header, &block );
722 }
723
724 if( contour->total == 0 )
725 return -1;
726
727 cvStartReadSeq( contour, &reader, 0 );
728 flag = 1;
729
730 if( CV_SEQ_ELTYPE( contour ) == CV_32SC2 )
731 {
732 CvPoint *prev_pt = (CvPoint*)reader.prev_elem;
733 CvPoint *cur_pt = (CvPoint*)reader.ptr;
734
735 int dx0 = cur_pt->x - prev_pt->x;
736 int dy0 = cur_pt->y - prev_pt->y;
737
738 for( i = 0; i < contour->total; i++ )
739 {
740 int dxdy0, dydx0;
741 int dx, dy;
742
743 /*int orient; */
744 CV_NEXT_SEQ_ELEM( sizeof(CvPoint), reader );
745 prev_pt = cur_pt;
746 cur_pt = (CvPoint *) reader.ptr;
747
748 dx = cur_pt->x - prev_pt->x;
749 dy = cur_pt->y - prev_pt->y;
750 dxdy0 = dx * dy0;
751 dydx0 = dy * dx0;
752
753 /* find orientation */
754 /*orient = -dy0 * dx + dx0 * dy;
755 orientation |= (orient > 0) ? 1 : 2;
756 */
757 orientation |= (dydx0 > dxdy0) ? 1 : ((dydx0 < dxdy0) ? 2 : 3);
758

Callers 1

isContourConvexMethod · 0.85

Calls 2

cvPointSeqFromMatFunction · 0.85
cvStartReadSeqFunction · 0.85

Tested by

no test coverage detected