| 42 | #include "precomp.hpp" |
| 43 | |
| 44 | CV_IMPL CvSeq* cvPointSeqFromMat( int seq_kind, const CvArr* arr, |
| 45 | CvContour* contour_header, CvSeqBlock* block ) |
| 46 | { |
| 47 | CV_Assert( arr != 0 && contour_header != 0 && block != 0 ); |
| 48 | |
| 49 | int eltype; |
| 50 | CvMat hdr; |
| 51 | CvMat* mat = (CvMat*)arr; |
| 52 | |
| 53 | if( !CV_IS_MAT( mat )) |
| 54 | CV_Error( CV_StsBadArg, "Input array is not a valid matrix" ); |
| 55 | |
| 56 | if( CV_MAT_CN(mat->type) == 1 && mat->width == 2 ) |
| 57 | mat = cvReshape(mat, &hdr, 2); |
| 58 | |
| 59 | eltype = CV_MAT_TYPE( mat->type ); |
| 60 | if( eltype != CV_32SC2 && eltype != CV_32FC2 ) |
| 61 | CV_Error( CV_StsUnsupportedFormat, |
| 62 | "The matrix can not be converted to point sequence because of " |
| 63 | "inappropriate element type" ); |
| 64 | |
| 65 | if( (mat->width != 1 && mat->height != 1) || !CV_IS_MAT_CONT(mat->type)) |
| 66 | CV_Error( CV_StsBadArg, |
| 67 | "The matrix converted to point sequence must be " |
| 68 | "1-dimensional and continuous" ); |
| 69 | |
| 70 | cvMakeSeqHeaderForArray( |
| 71 | (seq_kind & (CV_SEQ_KIND_MASK|CV_SEQ_FLAG_CLOSED)) | eltype, |
| 72 | sizeof(CvContour), CV_ELEM_SIZE(eltype), mat->data.ptr, |
| 73 | mat->width*mat->height, (CvSeq*)contour_header, block ); |
| 74 | |
| 75 | return (CvSeq*)contour_header; |
| 76 | } |
| 77 | |
| 78 | namespace cv |
| 79 | { |
no test coverage detected