cv2.imshow python

asked 2014-04-21 10:58:31 -0500

La Rosa gravatar image

can any body tell me whart is worng with this code cause when i run it i get no errors and yet no image is shown

from VideoCapture import Device

import cv2

import cv2.cv as cv

cam = Device(0)

cam.saveSnapshot('imageL.jpg')

fn = 'C:\Python276\imageL.jpg'

imageL = cv2.imread(fn,0)

cv2.imshow('Left',imageL)

if cv2.waitKey(1) & 0xFF == 27:

    cv.DestroyAllWindows()
edit retag flag offensive close merge delete

Comments

cv2.waitKey(1) might be too short ( unless you run it in a loop ) try:

cv2.waitKey() # wait forever
berak gravatar imageberak ( 2014-04-21 11:28:53 -0500 )edit

thank you so much it works but could you tell me what is the difference ( i'm a little bit new in opencv)

La Rosa gravatar imageLa Rosa ( 2014-04-21 11:35:29 -0500 )edit

the number you put there is the time it should wait in milliseconds. so, one milli is a bit too short.

0 or -1 as argument will make it wait endlessly (until you press something)

berak gravatar imageberak ( 2014-04-21 11:42:36 -0500 )edit

okay thank you

La Rosa gravatar imageLa Rosa ( 2014-04-21 11:46:23 -0500 )edit