cvPolyLine

//运行参数: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;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值