现在的位置: 首页 > 综合 > 正文

绘多边形

2014年01月28日 ⁄ 综合 ⁄ 共 737字 ⁄ 字号 评论关闭
#include <cv.h>    
#include <highgui.h>
#include <malloc.h>

int main(int argc, char* argv[])   
{   

	int arr[1];   
	arr[0] = 4;
	 
	//CvPoint ** pt;
	//pt = (CvPoint **)malloc();

	CvPoint ** pt = new CvPoint*[1];  
	pt[0] = new CvPoint[4];

	pt[0][0] = cvPoint(0,0);   
	pt[0][1] = cvPoint(100,10);   
	pt[0][2] = cvPoint(30,60);   
	pt[0][3] = cvPoint(10,100);   
	IplImage* image = cvCreateImage(cvSize(200,200), IPL_DEPTH_8U, 3); 

	int nCurves = 1;
	int isCurveClosed = 1;//闭合
	int lineWidth = 4;
	cvPolyLine( image, pt, arr, nCurves, isCurveClosed, CV_RGB(255,0,255), lineWidth);//#define CV_RGB( r, g, b )  cvScalar( (b), (g), (r), 0 )
	cvFillPoly(image, pt, arr, nCurves, CV_RGB(255,255,0));
	// 创建窗口
	cvNamedWindow("多边形", CV_WINDOW_AUTOSIZE);
	cvMoveWindow("多边形", 130, 150);
	// 显示图像
	cvShowImage("多边形", image);
	cvWaitKey(0);
	cvReleaseImage(&image);
	cvDestroyWindow("多边形");

	
	return 0;   
}   

抱歉!评论已关闭.