《Learning OpenCV3》——第六章 绘图和注释

第六章 绘图和注释

OpenCV3提供在图像上绘图的功能。一般状况下,绘图操做涉及单通道(灰度图像)和三通道(彩色图像)操做,Alpha通道的绘制暂时不支持。此外,OpenCV3组织彩色图像的方式为BGR排列,而不是常见的RGB排列顺序。web

一:线和填充多边形

线绘制的时候每每会涉及两个参数: thickness和lineType 。通常lineType取值有三种:4,8或者cv::LINE_AA;thickness为线的宽度,对于圆形、矩形或者一些其余的封闭多边形,thickness能够设置为cv::FILLED,此时将对多边形使用边界颜色进行填充。
这里写图片描述
通常来讲,绘图的起始点、结束点、角点等参数都为整数类型,但OpenCV3绘制函数支持的 shitf 参数能够进行亚像素点即非整数点的绘制。通常在绘制函数中传入shift值做为小数位数使用。
绘图功能:app

函数 描述
cv::circle() Draw a simple circle
cv::clipLine() Determine if a line is inside a given box
cv::ellipse() Draw an ellipse, which may be tilted or an elliptical arc
cv::ellipse2Poly() Compute a polygon approximation to an elliptical arc
cv::fillConvexPoly() Draw filled versions of simple polygons
cv::fillPoly() Draw filled versions of arbitrary polygons
cv::line() Draw a simple line

二:字体和文本

文本绘制功能:ide

函数 描述
cv::putText() Draw the specified text in an image
cv::getTextSize() Determine the width and height of a text string