当我运行这段代码时,本应在黑色表面上画一条直线,但是既没有出现任何错误信息,也没有显示任何内容。出了什么问题?
import numpy as np
import cv2
class DessinerLigne:
def dessinerLigne(self):
# Create a black image
self.img=np.zeros((512,512,3),np.uint8)
# Draw a diagonal blue line with thickness of 5 px
self.img=cv2.line(self.img,(0,0),(511,511),(255,0,0),5)
# If q is pressed then exit program
self.k=cv2.waitKey(0)
if self.k==ord('q'):
cv2.destroyAllWindows()
if __name__=="__main__":
DL=DessinerLigne()
DL.dessinerLigne()
waitKey
之前缺少类似于cv2.imshow("windowname", self.img)
的代码? - Micka