//运行参数:girl.jpg
#pragma comment(lib,"highgui.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"ml.lib")
#pragma comment(lib,"cvaux.lib")
#pragma comment(lib,"cvcam.lib")
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
IplImage* pImg; //声明IplImage指针
//载入图像,强制转化为Gray
if( argc == 2 && (pImg = cvLoadImage( argv[1], CV_LOAD_IMAGE_UNCHANGED)) != 0 )
{
// 在点 (100,100) 和 (200,200) 之间绘制一矩形,边线用红色、宽度为 1
cvRectangle(pImg, cvPoint(100,100), cvPoint(200,200), cvScalar(0,0,255), 1);
// 圆心为(100,100)、半径为20. 圆周绿色、宽度为1
cvCircle(pImg, cvPoint(100,100), 20, cvScalar(0,255,0), 1);
// 在 (100,100) 和 (200,200) 之间、线宽为 1 的绿色线段
cvLine(pImg, cvPoint(100,100), cvPoint(200,200), cvScalar(0,255,0), 1);
CvPoint curve1[]={10,10, 10,100, 100,100, 100,10};
CvPoint curve2[]={30,30, 30,130, 130,130, 130,30, 150,10};
CvPoint curve3[]={50,50, 50,150, 150,150, 150,50, 120,10, 100,0};
CvPoint* curveArr[3]={curve1, curve2,curve3};
int nCurvePts[3]={4,5,6};
int nCurves=3;
int isCurveClosed=1;
int lineWidth=1;
cvPolyLine(pImg,curveArr,nCurvePts,nCurves,isCurveClosed,cvScalar(255,0,0),lineWidth);
/*
void cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, int is_closed,
CvScalar color, int thickness=1, int line_type=8, int shift=0 );
img 图像。
pts 折线的顶点指针数组。
npts 折线的定点个数数组。也可以认为是pts指针数组的大小
contours 折线的线段数量。
is_closed 指出多边形是否封闭。如果封闭,函数将起始点和结束点连线。
color 折线的颜色。
thickness 线条的粗细程度。
line_type 线段的类型。参见cvLine。
shift 顶点的小数点位数
*/
cvNamedWindow( "Image", 1 ); // 创建窗口
cvShowImage( "Image", pImg ); // 显示图像
cvWaitKey(0); // 等待按键
cvDestroyWindow( "Image" ); // 销毁窗口
cvReleaseImage( &pImg ); // 释放图像
return 0;
}
return -1;
}
cvPolyLine
最新推荐文章于 2024-08-30 10:41:30 发布