我已經從opencv庫中給出的shape.c中獲取了代碼並進行了一些修改。OPENCV:我想在循環中繪製基本形狀,每次繪製新形狀時刪除舊形狀
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
int main(int argc, char** argv)
{
int i = 0;
for(i=0;i<3 ;i++)
{
/* create an image */
IplImage *img = cvCreateImage(cvSize(200, 100), IPL_DEPTH_8U, 3);
/* draw a green line */
cvLine(img, /* the dest image */
cvPoint(10 +i*10, 10), /* start point */
cvPoint(150, 80), /* end point */
cvScalar(0, 255, 0, 0), /* the color; green */
1, 8, 0); /* thickness, line type, shift */
/* draw a blue box */
cvRectangle(img, /* the dest image */
cvPoint(20, 15+i*10), /* top left point */
cvPoint(100, 70), /* bottom right point */
cvScalar(255, 0, 0, 0), /* the color; blue */
1, 8, 0); /* thickness, line type, shift */
/* draw a red circle */
cvCircle(img, /* the dest image */
cvPoint(110, 60), 35+i*10, /* center point and radius */
cvScalar(0, 0, 255, 0), /* the color; red */
1, 8, 0); /* thickness, line type, shift */
/* display the image */
cvNamedWindow("img", CV_WINDOW_AUTOSIZE);
cvShowImage("img", img);
cvWaitKey(0);
cvDestroyWindow("img");
cvReleaseImage(&img);
}
return 0;
}
我想,只要我遞增,老數字應被刪除,只有新的數字應該drawn.But什麼,我得到的是,隨着新的數據舊數據也present.Can沿着你幫幫我好嗎? 。
也許不是你的問題,但你每次打開一個新窗口。 – Blender