詳解opencv中畫圓circle函數(shù)和橢圓ellipse函數(shù)
1. void ellipse(InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle,
const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0);
ellipse函數(shù)將橢圓畫到圖像 lmg 上, 橢圓中心為點(diǎn)center,并且大小位于矩形 axes 內(nèi),橢圓旋轉(zhuǎn)角度為 angle, 擴(kuò)展的弧度從 0 度到 360 度,
圖形顏色為 Scalar(x, y,z),線寬 (thickness)為 1,線型(lineType)為 8 (8 聯(lián)通線型)。
2. void circle(InputOutputArray img, Point center, int radius, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0);
img :表示輸入的圖像
center: 圓心坐標(biāo)
radius: 圓的半徑
color:Scalar類型,表示圓的顏色,例如藍(lán)色為Scalar(255,0,0)
thickness:線的寬度
lineType:線的類型,(默認(rèn)為8聯(lián)通型)
#include<iostream> #include<opencv2/opencv.hpp> using namespace cv; using namespace std; #define WINDOW_NAME1 "繪制圖1" #define WINDOW_NAME2 "繪制圖2" #define WINDOW_WIDTH 600 //定義窗口大小 string image = "C:\\Users\\asus\\Pictures\\Saved Pictures\\123.jpg"; void DrawEllipse(Mat img, double angle); void DrawFi1ledCirc1e(Mat img, Point center); int main() { Mat atomImage = Mat::zeros(WINDOW_WIDTH, WINDOW_WIDTH, CV_8UC3); Mat rookImage = Mat::zeros(WINDOW_WIDTH, WINDOW_WIDTH, CV_8UC3); //繪制橢圓 DrawEllipse(atomImage, 90); DrawEllipse(atomImage, 0); DrawEllipse(atomImage, 45); DrawEllipse(atomImage, -45); //繪制圓心 DrawFi1ledCirc1e(atomImage, Point(WINDOW_WIDTH / 2,WINDOW_WIDTH / 2)); imshow(WINDOW_NAME1, atomImage); waitKey(0); return 0; } void DrawEllipse(Mat img, double angle) { int thickness = 2; int lineType = 8; ellipse(img, Point(WINDOW_WIDTH / 2, WINDOW_WIDTH / 2), Size(WINDOW_WIDTH / 4, WINDOW_WIDTH / 16), angle, 0, 360, Scalar(255, 129, 0), thickness, lineType); } void DrawFi1ledCirc1e(Mat img, Point center) { int thickness = -1; int lineType = 8; circle(img, center, WINDOW_WIDTH / 32, Scalar(0, 0, 255), thickness, lineType); }
總結(jié)
以上所述是小編給大家介紹的opencv中畫圓circle函數(shù)和橢圓ellipse函數(shù),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
python二分法查找算法實(shí)現(xiàn)方法【遞歸與非遞歸】
這篇文章主要介紹了python二分法查找算法實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Python使用遞歸與非遞歸算法實(shí)現(xiàn)二分查找的相關(guān)操作技巧,需要的朋友可以參考下2019-12-12解決Python 寫文件報(bào)錯TypeError的問題
這篇文章主要介紹了解決Python 寫文件報(bào)錯TypeError的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10基于Python實(shí)現(xiàn)繪制屬于你的世界地圖
Python之所以這么流行,是因?yàn)樗粌H能夠應(yīng)用于科技領(lǐng)域,還能用來做許多其他學(xué)科的研究工具,繪制地圖便是其功能之一。本文我們將用matplot工具包之一的 mpl_toolkits 來繪制世界地圖,需要的可以參考一下2022-11-11教你使用Python的pygame模塊實(shí)現(xiàn)拼圖游戲
pygame模塊是一個可以跨平臺的模塊,其設(shè)計(jì)目的就是為電子游戲而設(shè)計(jì),能夠支持圖片和聲音,下面這篇文章主要給給大家介紹了關(guān)于使用Python的pygame模塊實(shí)現(xiàn)拼圖游戲的相關(guān)資料,需要的朋友可以參考下2022-07-07