A CvContour is a structure with the same fields as CvSeq, plus several others, the most important of which is CvRect rect (see include / opencv / cxtypes.h). So it really comes down to what CvSeq is.
There is an opencv.pdf file that comes with OpenCV sources and on page 138 (for OpenCV 2.1) it says that CvSeq is defined as follows:
#define CV_SEQUENCE\_FIELDS() int flags; \ int header_size; \ struct CvSeq* h_prev; \ struct CvSeq* h_next; \ struct CvSeq* v_prev; \ struct CvSeq* v_next; \ int total; \ int elem_size; \ char* block_max; \ char* ptr; \ int delta_elems; \ CvMemStorage* storage; \ CvSeqBlock* free_blocks; \ CvSeqBlock* first; typedef struct CvSeq { CV_SEQUENCE_FIELDS() } CvSeq;
Let's say you call cvFindContours as follows:
cvFindContours(img, storage, &contours, sizeof(CvContour), CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
where contours will point to the first contour after calling cvFindContours . If you want to get your bounding box, you just pass it to cvBoundingRect . The next contour in the sequence can be obtained through contours->h_next . In the case of circuits, i.e. When the path can be inside another image path, you can access the first inner path of the current path through contours->v_next . The next inner contour, if it exists, will be contours->v_next->h_next , etc.
If you want to convert a sequence to an array, you can use cvCvtSeqToArray .
You can also use the C ++ interface starting with OpenCV 2.0, which seems to be better to use. For example, the parameter CvSeq** contours on cvFindContours becomes vector<vector<Point> >& contours .
carnieri
source share