Reputation: 1149
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:
as you can see there is still the blue bar on top
Upvotes: 17
Views: 63192
Reputation: 1
I had a case where the image on the Raspberry Pi was not displayed in full screen, but only at the top in a fixed size. It helped me to add another line to the above code.
import cv2
cap = cv2.VideoCapture(0)
width, height = cap.get(3), cap.get(4)
while True:
_, frame = cap.read()
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.moveWindow("window", int((Screen_Width/2)-(width/2)), int((Screen_Height/2)-(height/2)))
cv2.imshow("window", frame)
if cv2.waitKey(1) == 27: #Esc
cap.release()
cv2.destroyAllWindows()
break
Upvotes: 0
Reputation: 1149
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
Upvotes: 13
Reputation: 457
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)
Upvotes: 42
Reputation: 822
You have to create a window before doing your imshow. take a look here: http://docs.opencv.org/modules/highgui/doc/user_interface.html#namedwindow
Upvotes: 2