当前位置:网站首页>[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
边栏推荐
- idea必用插件
- Jsr303 and common validator implementations
- 安全帽佩戴检测算法研究
- 9:第三章:电商工程分析:4:【通用模块】;(待写……)
- Property or method “approval1“ is not defined on the instance but referenced during render
- Lambda expression_ Stream stream_ File class
- 香港回归25周年 香港故宫博物馆正式开放成文化新地标
- Php7.3 centos7.9 installing sqlserver extensions
- JSR303以及常见Validator实现
- Data security compliance has brought new problems to the risk control team
猜你喜欢
Consolidate entry-C basic variables and constants
Restartprocessifvisible process
Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd
How to connect the Internet Reading Notes - Summary
名单揭晓 | 2021年度中国杰出知识产权服务团队
Exception class_ Log frame
redis数据结构分析
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
更多龙蜥自研特性!生产可用的 Anolis OS 8.6 正式发布
Niuke: how many different binary search trees are there
随机推荐
[Demo] 循环写文件
HMS core audio editing service 3D audio technology helps create an immersive auditory feast
TCP socket and TCP connection
您工厂的MES再不升级,就要被淘汰啦
addmodule_allmerge_ams_im
删除有序数组中的重复项 II[双指针--多情况统一]
Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
Rongsheng biology rushes to the scientific innovation board: it plans to raise 1.25 billion yuan, with an annual revenue of 260million yuan
restartProcessIfVisible的流程
Exercise book of introduction to database system
"Promotion + funny plot", how to collide with the sparks of popular funds?
9:第三章:电商工程分析:4:【通用模块】;(待写……)
商单视频播放超2000万!农院改造为何屡被催更?
Nut cloud - sync files on your mobile hard drive on your new computer
编译丨迅为STM32P157开发板编译U-Boot源码
Additional: (not written yet, don't look at ~ ~ ~) webmvcconfigurer interface;
In order to make remote work unaffected, I wrote an internal chat room | community essay
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
Redis elimination strategy