其他分享
首页 > 其他分享> > cv2.ellipse()

cv2.ellipse()

作者:互联网

OpenCV-Python是旨在解决计算机视觉问题的Python绑定库。cv2.ellipse()方法用于在任何图像上绘制椭圆。

cv2.ellipse(image, centerCoordinates, axesLength, angle, startAngle, endAngle, color [, thickness[, lineType[, shift]]])

参数:

返回值:它返回一个图像。

用于以下所有示例的图像:

示例1:

# Python program to explain cv2.ellipse() method  
    
# importing cv2  
import cv2  
    
# path  
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'
    
# Reading an image in default mode 
image = cv2.imread(path) 
    
# Window name in which image is displayed 
window_name = 'Image'
   
center_coordinates = (120, 100) 
  
axesLength = (100, 50) 
  
angle = 0
  
startAngle = 0
  
endAngle = 360
   
# Red color in BGR 
color = (0, 0, 255) 
   
# Line thickness of 5 px 
thickness = 5
   
# Using cv2.ellipse() method 
# Draw a ellipse with red line borders of thickness of 5 px 
image = cv2.ellipse(image, center_coordinates, axesLength, 
           angle, startAngle, endAngle, color, thickness) 
   
# Displaying the image  
cv2.imshow(window_name, image) 

输出:

示例2:
使用-1 px的厚度和30度的旋转。

# Python program to explain cv2.ellipse() method 
    
# importing cv2 
import cv2 
    
# path 
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'
    
# Reading an image in default mode 
image = cv2.imread(path) 
    
# Window name in which image is displayed 
window_name = 'Image'
   
center_coordinates = (120, 100) 
  
axesLength = (100, 50) 
  
angle = 30
  
startAngle = 0
  
endAngle = 360
   
# Blue color in BGR 
color = (255, 0, 0) 
   
# Line thickness of -1 px 
thickness = -1
   
# Using cv2.ellipse() method 
# Draw a ellipse with blue line borders of thickness of -1 px 
image = cv2.ellipse(image, center_coordinates, axesLength, angle, 
                          startAngle, endAngle, color, thickness) 
   
# Displaying the image 
cv2.imshow(window_name, image) 

输出:

 

 

承接Matlab、Python和C++的编程,机器学习、计算机视觉的理论实现及辅导,本科和硕士的均可,咸鱼交易,专业回答请走知乎,详谈请联系QQ号757160542,非诚勿扰。

 

 

 


 

标签:name,color,image,cv2,thickness,ellipse
来源: https://blog.csdn.net/weixin_36670529/article/details/113817876