#create a image and test draw it
创建一张图片,需要定义图片各个属性,包括大小,图片像素类型(每个像素点用多少bits表示),通道数3(rgb)
import cv2.cv as cv
width = 200
height = 200
no_of_bits = 8
channels = 3
image = cv.CreateImage((width,height), no_of_bits, channels)
创建显示窗口
win_name = "test"
cv.NamedWindow("test",cv.CV_WINDOW_AUTOSIZE)
cv.ShowImage(win_name, image)
画一条直线,只需定义两个顶点坐标和线的宽度以及颜色
线的属性有颜色 , 宽度, 线类型(当线的宽度为-1时,矩形与圆形将是实心,及颜色填充)
#draw a line
x = 10
y = 10
start_point = (x,y)
x1 = 100
y1 = 100
end_point = (x1,y1)
#line attribute
color = (0,255,0)<