# Revision history [back]

This problem also occurred with me this morning, while i started leaning OpenCV, below solution worked for me, probably this will work for you people also:

# --------------------------------------------------

import numpy as np

import cv2

img = np.zeros((512, 512, 3), np.uint8)

img= cv2.line(img, (0, 0), (511, 511), (255, 0, 0), 5)

cv2.imshow("Image", img)

cv2.waitKey(0)

# ---------------------------------------------------

Basically, window with line disappears in mili-seconds, so we just need to **add a infinite wait key so that window does not get disappear automatically.

 2 No.2 Revision supra56 949 ●9 ●6

This problem also occurred with me this morning, while i started leaning OpenCV, below solution worked for me, probably this will work for you people also:

# --------------------------------------------------

import numpy as npnp
import cv2
import cv2 img = np.zeros((512, 512, 3), np.uint8) np.uint8)
img= cv2.line(img, (0, 0), (511, 511), (255, 0, 0), 5)5)
cv2.imshow("Image", img) cv2.waitKey(0) ---------------------------------------------------img)
cv2.waitKey(0)


Basically, window with line disappears in mili-seconds, so we just need to **add a infinite wait key so that window does not get disappear automatically.