问题如下:
我画了一条线,而且想让矩形在线所在的窗口关闭后才出现,但为什么矩形所在的窗口会在线所在的窗口还没被破坏时,就出现了呢?
代码如下:
# -*- coding:utf-8 -*-
import cv2
import numpy
from cv2 import LINE_8 #线的类型
from cv2 import LINE_AA #线的类型
img=numpy.zeros((512,512,3),numpy.uint8)
cv2.line(img,pt1=(0,0),pt2=(511,50),color=(255,255,255),thickness=5,lineType=LINE_AA)
cv2.imshow('Line',img)
while True:
if cv2.waitKey(1)!=-1:
break
cv2.destroyWindow('line')
img=numpy.ones((512,512,3),numpy.uint8)
img*=255
cv2.rectangle(img,pt1=(50,50),pt2=(130,200),color=(0,255,255),thickness=5)
cv2.imshow('Rectangle',img)
while True:
if cv2.waitKey(1)!=-1:
break
cv2.destroyWindow('rectangle')
结果如下:
请指点