03 cvPolyLine,連續畫線

openCV 的連續畫線指令

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include
#include
#include
using namespace cv;
int main(int argc,char **argv)
{
    int width,height;
    if(argc<=1)
    {
        std::cout<<"Error:Please Load a picture!"<<std::endl;         return 0;     } IplImage *image; //建立視窗 namedWindow("image",CV_WINDOW_AUTOSIZE); //讀取圖片 image=cvLoadImage(argv[1]); width=image->width;
height=image->height;

CvPoint PointArray1[6];
CvPoint *PointArray[2]= {&PointArray1[0],&PointArray1[3]};

PointArray[0][0]=cvPoint((width/6)*1,(height/6)*3);
PointArray[0][1]=cvPoint((width/6)*2,(height/6)*2);
PointArray[0][2]=cvPoint((width/6)*3,(height/6)*2);
PointArray[1][0]=cvPoint((width/6)*4,(height/6)*3);
PointArray[1][1]=cvPoint((width/6)*3,(height/6)*4);
PointArray[1][2]=cvPoint((width/6)*2,(height/6)*4);

int PolyVertexNumber[1]={6};
int BlockNumber=1;

cvPolyLine(image,PointArray,PolyVertexNumber,
1,true,CV_RGB(0,255,0),3,CV_AA,0);

cvShowImage("image",image);

waitKey(0);

cvDestroyAllWindows();
cvReleaseImage(&image);
system("pause");
return 0;
}

1-15

OpenCV
CH01 簡介CH02 OpenCV APICH03 繪圖CH04 應用範例CH06 haarcascadesCH06 surf和siftCH07 OCRCH09 FaceCH5 輪廓(findContours、drawContours)