Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display a full screen images with python2.7 and opencv2.4

I am trying to create a sort of image player with python and opencv. The images that i show are the same resolution on my screen and i would like to display them bordless in a full screen mode (without the windows bar at the bottom and the image bar at the top).

I accept also advice in order to improve my "var" used a counter for displaying the images:)

Thanks

def main():
    var= 0
    while True:
        print 'loading images...'
        if var==0:
            img =  cv2.imread('2-c.jpg')
            var=var+1
        else:
            img =  cv2.imread('2-d.jpg')
        cv2.imshow("test",img)
        key=cv2.waitKey(0)
        if key==27:
            break

EDIT: I post an image and maybe i can explain myself better: http://i39.tinypic.com/mhw1ev.jpg as you can see there is still the blue bar on top

like image 324
Gianfra Avatar asked Jul 17 '13 09:07

Gianfra


People also ask

How do I display an image full screen in Python?

If you want to show the image full-screen, you'll need to manually use the subprocess module to spawn some image viewing application that accepts command-line arguments to tell it to display the image in full-screen mode. You'll likely also need to create your own temporary image file to pass to it as well.

How do I open an image in opencv2?

The first Command line argument is the image image = cv2. imread(sys. argv[1]) #The function to read from an image into OpenCv is imread() #imshow() is the function that displays the image on the screen. #The first value is the title of the window, the second is the image file we have previously read.


2 Answers

Here is how I did it on my end:

cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.imshow("window", img)
like image 61
Nicolas Avatar answered Sep 18 '22 18:09

Nicolas


Thanks to Poko, I am gonna post the solution:

def main():
    var= 0
    while True:
        print('loading images...')
        if var==0:
            img =  cv2.imread('2-c.jpg')
            var=var+1
        else:
            img =  cv2.imread('2-d.jpg')
        cv2.namedWindow("test", cv2.WND_PROP_FULLSCREEN)          
        cv2.setWindowProperty("test", cv2.WND_PROP_FULLSCREEN, cv2.CV_WINDOW_FULLSCREEN)
        cv2.imshow("test",img)
        key=cv2.waitKey(0)
        if key==27:
            break
like image 23
Gianfra Avatar answered Sep 19 '22 18:09

Gianfra