詳解opencv中畫(huà)圓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ù)將橢圓畫(huà)到圖像 lmg 上, 橢圓中心為點(diǎn)center,并且大小位于矩形 axes 內(nèi),橢圓旋轉(zhuǎn)角度為 angle, 擴(kuò)展的弧度從 0 度到 360 度,
圖形顏色為 Scalar(x, y,z),線(xiàn)寬 (thickness)為 1,線(xiàn)型(lineType)為 8 (8 聯(lián)通線(xià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èi)型,表示圓的顏色,例如藍(lán)色為Scalar(255,0,0)
thickness:線(xiàn)的寬度
lineType:線(xiàn)的類(lèi)型,(默認(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中畫(huà)圓circle函數(shù)和橢圓ellipse函數(shù),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
python二分法查找算法實(shí)現(xiàn)方法【遞歸與非遞歸】
這篇文章主要介紹了python二分法查找算法實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析了Python使用遞歸與非遞歸算法實(shí)現(xiàn)二分查找的相關(guān)操作技巧,需要的朋友可以參考下2019-12-12
解決Python 寫(xiě)文件報(bào)錯(cuò)TypeError的問(wèn)題
這篇文章主要介紹了解決Python 寫(xiě)文件報(bào)錯(cuò)TypeError的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-10-10
python讀取與寫(xiě)入tif圖片的完整信息(過(guò)程詳解)
這篇文章主要介紹了python讀取與寫(xiě)入tif圖片的完整信息,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-05-05
基于Python實(shí)現(xiàn)繪制屬于你的世界地圖
Python之所以這么流行,是因?yàn)樗粌H能夠應(yīng)用于科技領(lǐng)域,還能用來(lái)做許多其他學(xué)科的研究工具,繪制地圖便是其功能之一。本文我們將用matplot工具包之一的 mpl_toolkits 來(lái)繪制世界地圖,需要的可以參考一下2022-11-11
教你使用Python的pygame模塊實(shí)現(xiàn)拼圖游戲
pygame模塊是一個(gè)可以跨平臺(tái)的模塊,其設(shè)計(jì)目的就是為電子游戲而設(shè)計(jì),能夠支持圖片和聲音,下面這篇文章主要給給大家介紹了關(guān)于使用Python的pygame模塊實(shí)現(xiàn)拼圖游戲的相關(guān)資料,需要的朋友可以參考下2022-07-07

