opencv+python(图形绘制)

1、画直线

 line(img: ndarray,
         pt1: Sequence[int],#起点
         pt2: Sequence[int],#终点
         color: Sequence[float],#颜色
         thickness: int = ...,#宽度
         lineType: int = ...,# 线形
         shift: int = ...)# 缩放比

2、画矩形

cv2.rectangle(img,(150,150),(300,300),(0,0,255),5,8)
  cv2.line(img,(150,150),(300,300),(0,0,255),5,4)  
  cv2.rectangle(img,(150,150),(300,300),(0,0,255),5,8)

   cv2.imshow("img",img)
   cv2.waitKey(0)

3、画圆

circle(img: ndarray,
           center: Sequence[int], #圆心
           radius: int,  #半径
           color: Sequence[float],
           thickness: int = ...,
           lineType: int = ...,
           shift: int = ...

 cv2.circle(img,(150,150),100,(0,0,255),5,8)

4、画椭圆

 ellipse(img: ndarray,
            center: Sequence[int],#圆心
            axes: Sequence[int],#轴半径的x与y
            angle: float,  #角度
            startAngle: float,#起始角度
            endAngle: float,#终点角度 注意是逆时针旋转的
            color: Sequence[float],
            thickness: int = ...,
            lineType: int = ...,
            shift: int = ...)

cv2.ellipse(img,(150,150),(50,150),0,0,360,(0,0,255))

5、多边形绘制

 polylines(img: ndarray,
             [pts]: Sequence[ndarray],#各个点的坐标,这个地方[]不能省略
              isClosed: bool,
              color: Sequence[float],
              thickness: int = ...,
              lineType: int = ...,
              shift: int = ...)

pts =np.array([(250,250),(150,150),(100,50),(150,0),(250,250)],np.int32)
cv2.polylines(img,[pts],True,(0,0,255))

cv2.fillPoly(img,[pts],(0,0,255)) #填充颜色

相关推荐

  1. OpenCV-绘制图形

    2024-04-08 15:40:01       40 阅读
  2. opencv+python(图形绘制)

    2024-04-08 15:40:01       39 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-08 15:40:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-08 15:40:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-08 15:40:01       82 阅读
  4. Python语言-面向对象

    2024-04-08 15:40:01       91 阅读

热门阅读

  1. set feedback 和set define

    2024-04-08 15:40:01       50 阅读
  2. 介绍 TensorFlow 的基本概念和使用场景。

    2024-04-08 15:40:01       40 阅读
  3. 将下载的jar依赖导入到本地依赖库(oracle、DM)

    2024-04-08 15:40:01       40 阅读
  4. 魔众 文库配置异步转换

    2024-04-08 15:40:01       37 阅读
  5. 【力扣】7. 整数反转

    2024-04-08 15:40:01       36 阅读
  6. redis内存淘汰策略

    2024-04-08 15:40:01       37 阅读
  7. SQL知识点:UNION ALL

    2024-04-08 15:40:01       33 阅读