Lynn Le
Lynn Le

Reputation: 113

OpenCV Python: Play video FULLSCREEN on second monitor with Python?

I'm using my Macbook (first monitor) to create an experimental set-up for a CRT monitor (second monitor).

This function displays the window on my first monitor.

def play_vid(vid_filename):
    cap = cv2.VideoCapture(path_to_vid + vid_filename )
    if (cap.isOpened()== False): 
        print("Error opening video stream or file")
    else:
    while(cap.isOpened()):
      # Capture frame-by-frame
        ret, frame = cap.read()
        if ret == True: 
            capname = "cap"
            cv2.namedWindow(capname, cv2.WND_PROP_FULLSCREEN)
            cv2.setWindowProperty(capname, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
            cv2.imshow(capname, frame)
            cv2.waitKeyEx(40)
        else: 
            break    

Is it possible to use cv2 to display the window on a second monitor fullscreen?

Upvotes: 3

Views: 3359

Answers (1)

Naty Biton
Naty Biton

Reputation: 21

You can use the command:

cv2.moveWindow(capname, X, 0)

When X is the number of pixels on the X axis of the first monitor. I.e. with your resolution 1920X1080, X = 1920

Upvotes: 2

Related Questions