04 cvRectangle 正方形的外框

penCV 的畫連續畫線指令

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string.h>
#include <fstream>
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;
    
    // 畫出正方形的外框
    cvRectangle(image,
                cvPoint((width/4),(height/4)),
                cvPoint((width/4)*3,(height/4)*3),
                 CV_RGB(255,0,0),3,CV_AA,1);
    

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



Screen Shot 2014-11-27 at 11.29.02 PM