Ask Your Question

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.

click to hide/show revision 2
No.2 Revision

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

np 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.