图像处理imgproc -Drawing Functions 画图函数

来源:互联网 发布:浙江网络作协 编辑:程序博客网 时间:2024/05/21 08:38


Drawing Functions

  • circle
  • clipLine
  • ellipse 椭圆
  • ellipse2Poly
  • fillConvexPoly
  • fillPoly  
  • getTextSize
  • InitFont
  • line 线
  • arrowedLine
  • LineIterator
  • rectangle 矩形
  • polylines 多边形
  • drawContours 画轮廓
  • putText

#include<iostream>
#include<vector>
#include<opencv2/opencv.hpp>

using namespace cv;
using namespacestd;

int main()
{
    Mat srcImage(Size(300, 300), CV_8UC3, Scalar(0));

    Point p1 = Point(60, 50);
    Point p2 = Point(250, 200);

    line(srcImage, p1, p2, CV_RGB(255, 0, 0), 1);

    imshow("效果图", srcImage);
    waitKey();

    return 0;
} 平面坐标系画一条直线。

class rectangle 类 

void cv::rectangle  (  
InputOutputArray    img,      //图像
Point   pt1,                  //矩形的一个顶点
Point   pt2,                  //和上一个顶点相对的顶点
const Scalar &  color,        //线的颜色
int     thickness = 1,       //线的粗细
int     lineType = LINE_8,    //线的类型
int     shift = 0            //点坐标中小数位数
)   

构造函数

 实例:

#include<iostream>
#include<vector>
#include<opencv2/opencv.hpp>

using namespace cv;
using namespacestd;

int main()
{
    Mat srcImage(Size(300, 300), CV_8UC3, Scalar(0));

    Point p1 = Point(60, 50);
    Point p2 = Point(250, 200);

    rectangle(srcImage, p1, p2, CV_RGB(255, 0, 0), 1);

    imshow("效果图", srcImage);
    waitKey();

    return 0;
} 画一个矩形 

#include<iostream>
#include<vector>
#include<opencv2/opencv.hpp>

using namespace cv;
using namespacestd;

int main()
{
    Mat srcImage(Size(300, 300), CV_8UC3, Scalar(0));

    Point circle_center = Point(150, 150);

    int circle_radius = 80;

    circle(srcImage, circle_center, circle_radius, Scalar(255,0,0),2);   //Scalar( (b), (g), (r), 0 )

    imshow("效果图", srcImage);

    waitKey();

    return 0;

void cv::polylines  (  
InputOutputArray    img,    //图像
InputArrayOfArrays  pts,    //点集
bool    isClosed,           //true为闭合,最后一个点和第一个点连起来
const Scalar &  color,      //线的颜色
int     thickness = 1,     //线的粗细
int     lineType = LINE_8,  //线的类型
int     shift = 0          //点的坐标精度
)  

#include<iostream>  #include<vector>  #include<opencv2/opencv.hpp>  using namespace cv;using namespace std;int main(){    Mat srcImage(Size(300, 300), CV_8UC3, Scalar(0));    vector<Point> pt;    pt.push_back ( Point(50, 50) );    pt.push_back ( Point(50, 120) );    pt.push_back ( Point(90, 160) );    pt.push_back ( Point(140, 240) );    pt.push_back ( Point(240, 70) );    polylines(srcImage ,pt ,1, CV_RGB(0, 255, 0), 2);    imshow("效果图", srcImage);    waitKey();    return 0;}



  ColorMaps in OpenCV
 
  Planar Subdivision
 
  Histograms 直方图 




 

  提供便于计算的一些接口

结构分析和形状描述Structural Analysis and Shape Descriptors

这一部分提供2D图像的很多几何变换操作,例如非常实用的Resize等等。

 
  Motion Analysis and Object Tracking  运动分析与目标跟踪
 


(找边界)canny 
(找角)cornerEigenValsAndVecs,cornerHarris,cornerMinEigenVal,cornerSubPix,(预处理)preCornerDetect
goodFeaturesToTrack 
(找圆)HoughCircles 
(找线)HoughLines,HoughLinesP

 

就是模板匹配

——–3.2与2.4相比增添了以下内容: 
1.Drawing Functions绘画的功能: 
最实用的应该就是透明背景了吧,通过Scalar增加alpha位,之前所有的画圆,方,点线面的函数都可以直接调用cv::某个函数()在颜色位加上最后一位来实现半透明的效果。

Scalar(blue_component,green_component,red_component[,alpha_component]) 
  • 1

2.给灰度图重新上色ColorMaps in OpenCV 
功能函数为:void cv::applyColorMap (InputArray src, OutputArray dst, int colormap)
附上颜色对照表

这里写图片描述

3.平面细分Planar Subdivision 
cv::Subdiv2D 
用于三维定位等等…


 
  C API
 

  Hardware Acceleration Layer


原创粉丝点击