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;
}

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    

 

转载于:https://www.cnblogs.com/yunfung/p/7551387.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值