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); }