当前位置:网站首页>[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
边栏推荐
- Mathematical modeling for war preparation 33- grey prediction model 2
- HMS core audio editing service 3D audio technology helps create an immersive auditory feast
- Substrate 跨链技术源码级探索: XCVM的概览
- Delete duplicates in an ordered array ii[double pointers -- unified in multiple cases]
- 山西化工园区智能化管控平台建设时间表
- 巩固入门-C#基础变量和常量
- Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
- 补充材料 supplementary
- 深度学习——(2)几种常见的损失函数
- Mathematical modeling for war preparation 35 time series prediction model
猜你喜欢

Restartprocessifvisible process

Construction schedule of intelligent management and control platform in Shanxi Chemical Industry Park
![[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)

名单揭晓 | 2021年度中国杰出知识产权服务团队

HMS core audio editing service 3D audio technology helps create an immersive auditory feast

“推广+搞笑剧情”,如何碰撞出爆款的火花?
![Halcon knowledge: regional topics [07]](/img/18/680997127047fb24b0ee4f19d8f2c5.png)
Halcon knowledge: regional topics [07]

Etcd tutorial - Chapter 9 etcd implementation of distributed locks

八大基本排序(详解)

flutter自定义组件
随机推荐
坚果云-在新电脑上同步移动硬盘的文件
restartProcessIfVisible的流程
List becomes vector list becomes vector list vector
Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd
Construction schedule of intelligent management and control platform in Shanxi Chemical Industry Park
simpleITK读取nii遇到ITK only supports orthonormal direction cosines的错误
定时任务删除指定时间的的数据
geo 读取单细胞csv表达矩阵 单细胞 改列名 seurat
nodejs学习笔记二
Compile - compile for itop4412 development board makefile
The 25th anniversary of Hong Kong's return to China the Hong Kong Palace Museum officially opened as a new cultural landmark
STL教程7-set、pair对组和仿函数
addmodule_ allmerge_ ams_ im
香港回归25周年 香港故宫博物馆正式开放成文化新地标
Pref usage record
A scheduled task deletes data at a specified time
Research on helmet wearing detection algorithm
Data security compliance has brought new problems to the risk control team
[activity registration] it's your turn to explore the yuan universe! I will be waiting for you in Shenzhen on July 2!
JS ES5也可以创建常量?