OPENCV學習筆記1-6_圖像上繪圖

1.1 Related Class

  1. Class: OpenCV::CvPoint

  CvPoint:表示一個座標爲整數的二維點,是一個包含integer類型成員x和y的結構體。

typdef struct CvPoint {
  int x;         // X axis
  int y;         // Y axis
}
 2. Class: OpenCV::CvScalar

   CvScalar是一個包含四個元素的結構體變量。Element-value (元素)of one pixel. OpenCV supports the image of 4-channels in the maximum. Therefore, CvScalar has 4-values。

typdef struct CvScalar {
  double val[4];
} CvScalar;

1.2 Sample code  

#include <iostream>
#include <opencv2/opencv.hpp>            //含了OpenCV中各個模塊的頭文件 must or not able used circle
//#include <opencv2/core/core.hpp>
//#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

#define  height 480
#define  width  600

CvPoint CircleCenter;
int Radius;
CvScalar Color;
int Thickness;
int Shift;

int main()
{

    Mat image(height, width, CV_8UC3, Scalar(255, 255, 255));//(255, 255, 255); white (0, 0, 0) black
    CircleCenter = cvPoint(100, 100);
    Radius = 50;
    Color = CV_RGB(255, 0, 0);
    Thickness = 3;
    Shift = 0;

    circle(image, CircleCenter, Radius, Color, Thickness, Shift);

    putText(image,                  // destination image
        "This is a circle.",        // text
        Point(40, 200),             // text position
        FONT_HERSHEY_PLAIN,         // font type
        2.0,                        // font scale
        255,                        // text color (here white)
        2);                         // text thickness
    namedWindow("yunfung image", WINDOW_NORMAL);
    imshow("yunfung image", image);

    waitKey(0);
    return 0;
}

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章