当前位置:网站首页>[200 opencv routines] 215 Drawing approximate ellipse based on polyline
[200 opencv routines] 215 Drawing approximate ellipse based on polyline
2022-06-30 17:07:00 【Xiaobai youcans】
OpenCV routine 200 piece General catalogue
【youcans Of OpenCV routine 200 piece 】215. Draw approximate ellipses based on polylines
If you need more control over ellipse rendering , Or draw a rough elliptical boundary , have access to cv.ellipse2Poly Retrieve curve , Then render with polylines or use fillPoly Fill in .
The function prototype :
cv.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta[,]) → pts
Parameter description :
- img: Input / output image , Allows single channel grayscale images or multi-channel color images
- center: Coordinates of the center point of the ellipse ,(x, y) Tuple of format
- axes: Length of ellipse semi axis ,(hfirst, hsecond) Tuple of format -
- angle: Ellipse edge x Rotation angle in the axis direction ( Angle system , clockwise )
- arcStart: The starting angle of the elliptical arc ( Angle system )
- endAngle: The ending angle of an elliptical arc ( Angle system )
- delta: The angle with the next line segment , Used to control approximate accuracy , The smaller the angle, the closer it is to the ellipse
- pts: Output vector , An array of vertex coordinates of a polyline approximating an elliptical arc
# A4.6 Draw approximate ellipses based on polylines
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) # Draw approximate polygons
points[:,1] += 160
cv.fillPoly(img, [points], color) # Draw fill approximation polygons
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()

【 At the end of this section 】
Copyright notice :
[email protected] Original works , Reprint must be marked with the original link :(https://blog.csdn.net/youcans/article/details/125468099)
Copyright 2022 youcans, XUPT
Crated:2022-6-26
Welcome to your attention 『youcans Of OpenCV routine 200 piece 』 series , Ongoing update
Welcome to your attention 『youcans Of OpenCV Learning lessons 』 series , Ongoing update
210. There are so many holes in drawing a straight line ?
211. Draw vertical rectangle
212. Draw a slanted rectangle
213. Draw a circle
214. Detailed explanation of parameters for drawing ellipse
215. Draw approximate ellipses based on polylines
边栏推荐
- [wechat applet] basic use of common components (view/scroll-view/wiper, text/rich-text, button/image)
- 【JVM】类加载相关面试题——类加载过程、双亲委派模型
- pref使用记录
- leetcode:787. K 站中转内最便宜的航班【k步最短路 + dfs记忆化 + defaultdict(dict)】
- Parler du télétravail
- 您工厂的MES再不升级,就要被淘汰啦
- 列表变成向量 列表变向量 list vector
- Tutoriel etcd - chapitre 8 API compacte, Watch et lease pour etcd
- Pref usage record
- MySQL8 NDB Cluster安装部署
猜你喜欢

Exercise book of introduction to database system

Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API

【JVM】类加载相关面试题——类加载过程、双亲委派模型

Tutoriel etcd - chapitre 8 API compacte, Watch et lease pour etcd

Carry two load balancing notes and find them in the future

7 月 2 日邀你来TD Hero 线上发布会

List announced - outstanding intellectual property service team in China in 2021

"Promotion + funny plot", how to collide with the sparks of popular funds?

leetcode:787. K 站中转内最便宜的航班【k步最短路 + dfs记忆化 + defaultdict(dict)】

利用PIL进行不失真的resize
随机推荐
居家办公浅谈远程协助快速提效心得 | 社区征文
9: Chapter 3: e-commerce engineering analysis: 4: [general module]; (to be written...)
Php7.3 centos7.9 installing sqlserver extensions
删除有序数组中的重复项 II[双指针--多情况统一]
[JVM] takes you to learn about the garbage collection mechanism (GC) in the JVM -- including diagrams
Data mining knowledge points sorting (final review version)
山西化工园区智能化管控平台建设时间表
List becomes vector list becomes vector list vector
Internet R & D efficiency practice qunar core field Devops landing practice
Etcd教程 — 第九章 Etcd之实现分布式锁
基于51单片机的计件器设计
Redis elimination strategy
华为帐号多端协同,打造美好互联生活
八大基本排序(详解)
Required plug-ins for idea
Halcon knowledge: regional topics [07]
Mathematical modeling for war preparation 33- grey prediction model 2
编译丨迅为STM32P157开发板编译U-Boot源码
[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)
Niuke.com: minimum cost of climbing stairs