How to open webcam in fullscreen with python?

3

I have this basic code to open my webcam via python, but I do not know how to put it in fullscreen , could you help me?

import cv2

cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)

if vc.isOpened(): # try to get the first frame
    rval, frame = vc.read()
else:
    rval = False

while rval:
    cv2.imshow("preview", frame)
    rval, frame = vc.read()
    key = cv2.waitKey(20)
    if key == 27: # exit on ESC
        break
cv2.destroyWindow("preview")
    
asked by Noi Sk8 03.08.2018 в 15:51
source

1 answer

1

You can try with the parameter for FULLSCREEN that is called cv2.WND_PROP_FULLSCREEN in namedWindow and setWindowProperty

cv2.namedWindow("Foo" , cv2.WND_PROP_FULLSCREEN)    
cv2.setWindowProperty("Foo" ,
                      cv2.WND_PROP_FULLSCREEN,
                      cv2.WINDOW_FULLSCREEN)

You can search here Windows Property Flags In the Python section

    
answered by 03.08.2018 в 16:24