openCV 的連續畫線指令
[php]
#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;
}
[/php]