天天看點

《Learning OpenCV3》——第六章 繪圖和注釋第六章 繪圖和注釋

第六章 繪圖和注釋

  • 第六章 繪圖和注釋
    • 一線和填充多邊形
    • 二字型和文本

OpenCV3提供在圖像上繪圖的功能。通常情況下,繪圖操作涉及單通道(灰階圖像)和三通道(彩色圖像)操作,Alpha通道的繪制暫時不支援。此外,OpenCV3組織彩色圖像的方式為BGR排列,而不是常見的RGB排列順序。

一:線和填充多邊形

線繪制的時候往往會涉及兩個參數: thickness和lineType 。一般lineType取值有三種:4,8或者cv::LINE_AA;thickness為線的寬度,對于圓形、矩形或者一些其他的封閉多邊形,thickness可以設定為cv::FILLED,此時将對多邊形使用邊界顔色進行填充。

《Learning OpenCV3》——第六章 繪圖和注釋第六章 繪圖和注釋

一般來說,繪圖的起始點、結束點、角點等參數都為整數類型,但OpenCV3繪制函數支援的 shitf 參數可以進行亞像素點即非整數點的繪制。一般在繪制函數中傳入shift值作為小數位數使用。

繪圖功能:

函數 描述
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

二:字型和文本

文本繪制功能:

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

繼續閱讀