AIR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#-*- coding:utf-8 -*-

import numpy as np
import cv2 as cv

#draw line
#Create a black image
img=np.zeros((512,512,3),np.uint8) #(512,512,3)前两个参数代表建立图像大小,第一个是高,第二个是长,3代表RGB通道,可以出现彩色图像
#1是默认值,为灰度图像


#Draw a diagonal blue line with thickness of 5 px
'''cv :: line(InputOutputArray img,Point pt1,Point pt2,const Scalar&color,int thickness = 1,int lineType = LINE_8,int shift = 0)
绘制连接两个点的线段.'''
# IMG 图片。
# PT1 线段的第一点。
# PT2 线段的第二点。
# 颜色 线条颜色。
# 厚度 线的粗细。
# 线型 线的类型。请参见LineTypes。
# 转移 点坐标中的小数位数。
cv.line(img,(0,0),(511,511),(255,0,0),5)
#cv.imshow("Line",img)

#Draw a rectangle
cv.rectangle(img,(384,0),(510,128),(0,255,0),3)
#cv.imshow("Rectangel",img)

#Draw a circle
cv.circle(img,(384+63,64),63,(255,255,255),2)


#Draw an ellipse
#img=cv.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]] )
# img 图片。
# center 椭圆的中心。
# axes 椭圆主轴大小的一半。
# angle 椭圆旋转角度(以度为单位),顺时针方向旋转
# startAngle 椭圆弧的起始角度(以度为单位)。
# endAngle 椭圆弧的终止角度(以度为单位)。
# color 椭圆颜色。
# thickness 椭圆弧的轮廓粗细,如果是正的。否则,这表示将绘制填充的椭圆扇区。
# lineType 椭圆边界的类型。
# shift 中心坐标和轴值的小数位数。
cv.ellipse(img,(256,256),(100,50),0,0,180,(255,255,255),-1)

#Drawing Polygon
pts=np.array([[10,5],[20,30],[70,20],[50,10]],np.int32)
pts=pts.reshape((-1,1,2))
cv.polylines(img,[pts],1,(0,255,255))#如果第三个参数为False,您将获得连接所有点的折线,而不是闭合形状。

#Adding Text to Images
# img = cv.putText( img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]] )
# img 图片。
# text 要绘制的文本字符串。
# org 图像中文本字符串的左下角。
# fontFace 字体类型,请参阅HersheyFonts。
# fontScale 字体比例因子乘以字体特定的基本大小。
# color 文字颜色
# thickness 用于绘制文本的线条的粗细。
# lineType 线型。请参见LineTypes
# bottomLeftOrigin 如果为true,则图像数据原点位于左下角。否则,它位于左上角。

font=cv.FONT_HERSHEY_SIMPLEX
cv.putText(img,"OpenCV",(10,450),font,4,(255,255,0),2,cv.LINE_AA)

cv.imshow("Img",img)
cv.waitKey(0)

 Comments


Blog content follows the Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License

Use Material X as theme , total visits times .
载入天数...载入时分秒...