0
我試圖在使用cvDrawContours時使用CvPoint矢量繪製輪廓,但它並未在圖像上繪製輪廓但cvDrawRect完美地工作。請解釋下面的代碼是否有任何錯誤。Opencv cvDrawContours無法正常工作
IplImage *iplMaskKeyPoints = cvCreateImage(cvGetSize(iplObjGrey),iplObjGrey->depth,1);
CvMemStorage *msObjImgStorage = cvCreateMemStorage(0);
CvSeq* sqObjImgPoly = cvCreateSeq(CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), msObjImgStorage);
cvZero(iplMaskKeyPoints);
for(int i = 0; i < (int)vecObjPoly.size(); i++)
{
CvPoint pt = vecObjPoly[i];
cvSeqPush(sqObjImgPoly, &pt);
}
cvDrawContours(iplMaskKeyPoints,sqObjImgPoly,cvScalar(255,255,255),cvScalar(255,255,255),1,CV_FILLED);
cvShowImage("output",iplMaskKeyPoints);
cvWaitKey(0);
if(sqObjImgPoly != NULL)
{
cvClearSeq(sqObjImgPoly);
sqObjImgPoly = NULL;
}
if(msObjImgStorage != NULL)
{
cvClearMemStorage(msObjImgStorage);
cvReleaseMemStorage(&msObjImgStorage);
}
vecObjPoly.clear();
cvReleaseImage(&iplMaskKeyPoints);