当前位置:网站首页>【OpenCV 例程200篇】215. 基于多段线绘制近似椭圆
【OpenCV 例程200篇】215. 基于多段线绘制近似椭圆
2022-06-30 15:49:00 【小白YouCans】
【youcans 的 OpenCV 例程200篇】215. 基于多段线绘制近似椭圆
如果需要对椭圆渲染进行更多控制,或者绘制粗略的椭圆边界,可以使用 cv.ellipse2Poly 检索曲线,然后使用多段线进行渲染或使用fillPoly进行填充。
函数原型:
cv.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta[,]) → pts
参数说明:
- img:输入输出图像,允许单通道灰度图像或多通道彩色图像
- center:椭圆中心点的坐标,(x, y) 格式的元组
- axes:椭圆半轴长度,(hfirst, hsecond) 格式的元组-
- angle: 椭圆沿 x轴方向的旋转角度(角度制,顺时针方向)
- arcStart:椭圆弧的起始角度(角度制)
- endAngle:椭圆弧的终止角度(角度制)
- delta:与下一线段之间的角度,用于控制近似精度,角度越小越接近椭圆
- pts:输出向量,逼近椭圆弧的多段线顶点坐标的数组
# A4.6 基于多段线绘制近似椭圆
img = np.ones((400, 600, 3), np.uint8)*224
cx, cy = 100, 150
halfAxesLength = (70, 40)
angle, startAng, endAng = 30, 0, 360
delta = [10, 20, 30, 40]
for i in range(len(delta)):
color = (i*60, i*60, 255-i*60)
pts = cv.ellipse2Poly((cx+140*i, cy), halfAxesLength, angle, startAng, endAng, delta[i]) # (351,2)
points = np.array(pts)
cv.polylines(img, [points], True, color, thickness=1) # 绘制近似多边形
points[:,1] += 160
cv.fillPoly(img, [points], color) # 绘制填充近似多边形
text1 = "delta={}".format(delta[i])
text2 = "num={}".format(pts.shape)
cv.putText(img, text1, (140*i+25, 30), cv.FONT_HERSHEY_SIMPLEX, 0.5, 255)
cv.putText(img, text2, (140*i+25, 50), cv.FONT_HERSHEY_SIMPLEX, 0.5, 255)
print(pts.shape, points.shape)
plt.figure(figsize=(9, 6))
plt.title("Polygon approximated ellipse"), plt.axis('off')
plt.imshow(cv.cvtColor(img, cv.COLOR_BGR2RGB))
plt.show()

【本节完】
版权声明:
[email protected] 原创作品,转载必须标注原文链接:(https://blog.csdn.net/youcans/article/details/125468099)
Copyright 2022 youcans, XUPT
Crated:2022-6-26
欢迎关注 『youcans 的 OpenCV 例程 200 篇』 系列,持续更新中
欢迎关注 『youcans 的 OpenCV学习课』 系列,持续更新中
210. 绘制直线也会有这么多坑?
211. 绘制垂直矩形
212. 绘制倾斜的矩形
213. 绘制圆形
214. 绘制椭圆的参数详解
215. 基于多段线绘制近似椭圆
边栏推荐
- Parler du télétravail
- [machine learning] K-means clustering analysis
- simpleITK读取nii遇到ITK only supports orthonormal direction cosines的错误
- IndexSearch
- Halcon knowledge: matrix topic [02]
- idea必用插件
- Good partner for cloud skill improvement, senior brother cloud of Amazon officially opened today
- 2022 Blue Bridge Cup group B -2022- (01 backpack to calculate the number of schemes)
- geo 读取单细胞csv表达矩阵 单细胞 改列名 seurat
- 荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
猜你喜欢

Property or method “approval1“ is not defined on the instance but referenced during render

数据挖掘知识点整理(期末复习版)
![[wechat applet] the hosting environment of the applet](/img/ee/0f1dee4a26eb62c2268484c1b59edf.png)
[wechat applet] the hosting environment of the applet

On July 2, I invited you to TD Hero online conference

更多龙蜥自研特性!生产可用的 Anolis OS 8.6 正式发布

TCP socket and TCP connection
![[wechat applet] basic use of common components (view/scroll-view/wiper, text/rich-text, button/image)](/img/3b/05dbf03024088c5f94363f157a1701.png)
[wechat applet] basic use of common components (view/scroll-view/wiper, text/rich-text, button/image)

华为帐号多端协同,打造美好互联生活

Headhunter 50, 000, I'll go to VC

Exception class_ Log frame
随机推荐
定时任务删除指定时间的的数据
Niuke.com: minimum cost of climbing stairs
“推广+搞笑剧情”,如何碰撞出爆款的火花?
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
[Verilog basics] octal and hexadecimal representation of decimal negative numbers
Cmakelists Basics
POJ Project Summer
HMS core audio editing service 3D audio technology helps create an immersive auditory feast
坚果云-在新电脑上同步移动硬盘的文件
删除有序数组中的重复项 II[双指针--多情况统一]
Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation
IO stream_ recursion
荣盛生物冲刺科创板:拟募资12.5亿 年营收2.6亿
Exception class_ Log frame
The meaning of linetypes enumeration values (line_4, line_8, line_aa) in opencv
Wechat emoticons are written into the judgment, and the OK and bomb you send may become "testimony in court"
搬运两个负载均衡的笔记,日后省的找
How to connect the Internet Reading Notes - Summary
CMakeLists 基础
【JVM】类加载相关面试题——类加载过程、双亲委派模型