我在这里试图创建一个将CvMat作为其元素的序列。我编写的代码与
相同 for(CvSeq *c = first_contour;c!=NULL;c = c->h_next)
{
//New Seq created for each component seq in first_contour
CvSeq * newSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvMat),storage);
cvDrawContours(iOriginal,c,red,green,0,2,8);
//Printing the contour no.
printf("Contour == %d\n",nTmp);
cvShowImage("Countour Information",iOriginal);
//Printing the total no of elements in each sequence
printf("%d Elements",c->total);
//Creating a matrix with the dimension (total by 2)
CvMat * matBoundary = cvCreateMat(c->total,2,CV_64FC1);
//Iterating thru each seq to access its elements and setting it to matrix matBoundary
for(int i =0 ;i<c->total;i++)
{
CvPoint * p = CV_GET_SEQ_ELEM(CvPoint,c,i);
cvmSet(matBoundary,i,0,p->x);
cvmSet(matBoundary,i,1,p->y);
printf("(%d,%d)\n",p->x,p->y);
}
//Pushing new matrix's address in newSeq
cvSeqPush(newSeq,&matBoundary);
//Checking the contents of boundary mat
//for(CvSeq * s = boundarySeq;s!=NULL;s = s->h_next)
//{
CvMat * mat = CV_GET_SEQ_ELEM(CvMat,newSeq,1);
for(int i = 0;i<mat->rows;i++)
{
int x = cvmGet(mat,i,0);
int y = cvmGet(mat,i,0);
printf("x=%d y=%d",x,y);
}
任何人都能告诉我这是什么问题,因为我在'newSeq'中什么也没得到。