当前位置:网站首页>[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
边栏推荐
- Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation
- List announced - outstanding intellectual property service team in China in 2021
- Data mining knowledge points sorting (final review version)
- dart:字符串replace相关的方法
- Cmakelists Basics
- 为了使远程工作不受影响,我写了一个内部的聊天室 | 社区征文
- Mathematical modeling for war preparation 34-bp neural network prediction 2
- 2020 Blue Bridge Cup group B - move bricks - (greedy sorting +01 backpack)
- Undistorted resize using pil
- Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
猜你喜欢

Jsr303 and common validator implementations

Redis elimination strategy

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

Research on helmet wearing detection algorithm
![9: Chapter 3: e-commerce engineering analysis: 4: [general module]; (to be written...)](/img/96/cbed98ec69c952f1d231ce2ed25aab.png)
9: Chapter 3: e-commerce engineering analysis: 4: [general module]; (to be written...)

Consolidate entry-C basic variables and constants

编译丨迅为iTOP4412开发板Makefile编译

More dragon lizard self-developed features! Production available Anolis OS 8.6 officially released

居家办公浅谈远程协助快速提效心得 | 社区征文
![[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)](/img/54/fd7541dae4aad7e4216bcaabbb146b.png)
[Verilog basics] summary of some concepts about clock signals (clock setup/hold, clock tree, clock skew, clock latency, clock transition..)
随机推荐
[JVM] class loading related interview questions - class loading process and parental delegation model
Lambda expression_ Stream stream_ File class
TCP socket and TCP connection
differential analysis between different groups nichenet for silicosis成功运行!
Bc1.2 PD protocol
数据挖掘知识点整理(期末复习版)
A scheduled task deletes data at a specified time
您工厂的MES再不升级,就要被淘汰啦
补充材料 supplementary
巩固入门-C#基础变量和常量
Mathematical modeling for war preparation 33- grey prediction model 2
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
登录框Tricks
TCP Socket与TCP 连接
聊聊遠程辦公那些事兒 | 社區征文
阿里云盘分享压缩包
In order to make remote work unaffected, I wrote an internal chat room | community essay
Mathematical modeling for war preparation 36 time series model 2
Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan
Halcon knowledge: matrix topic [02]