opencv1.x绘制CvBox2D函数(绘制自定义轮廓CvSeq):
void DrawBox(CvBox2D box,IplImage* img,CvScalar scalar)
{
CvPoint2D32f point[4];
int i;
for ( i=0; i<4; i++)
{
point[i].x = 0;
point[i].y = 0;
}
cvBoxPoints(box, point);
CvPoint pt[4];
for ( i=0; i<4; i++)
{
pt[i].x = (int)point[i].x;
pt[i].y = (int)point[i].y;
}
CvMemStorage* store = cvCreateMemStorage(0);
CvSeq* seq = cvCreateSeq(CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_CURVE | CV_SEQ_FLAG_CLOSED,sizeof(CvContour),sizeof(CvPoint),store);
for (size_t i = 0; i < 4; i++)
{
cvSeqPush(seq,&pt[i]);
}
cvDrawContours(img,seq,scalar,scalar,1,3,8);
cvReleaseMemStorage(&store);
}