3

So I'm trying to display a video (named as test.mp4) with Python and OpenCV in full screen mode if possible and without showing OpenCV's cross cursor. Is there a way of doing this with some other library instead of OpenCV? Also I'm new to Stack Overflow so please say if I did something wrong.

I found out how to change name of window and size(full screen). Even though I'm not satisfied with "fullscreen" because it has some white edges on the sides. If someone knows why is that happening help.

This is the code:

import cv2
import numpy as np
on = "on"
file_name = "test.mp4"
window_name = "randomsheetblin"
interframe_wait_ms = 30

cap = cv2.VideoCapture(file_name)
if not cap.isOpened():
    print("Error: Could not open video.")
    exit()

cv2.namedWindow(window_name, cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

while on == "on":

    ret, frame = cap.read()
    if not ret:
        #print("Reached end of video, exiting.")
        break

    cv2.imshow(window_name, frame)
    if cv2.waitKey(interframe_wait_ms) & 0x7F == ord('p'):
        #print("Exit requested.")
        break

cap.release()
cv2.destroyAllWindows()

Result should be a fullscreen window with custom name, without OpenCV's cross cursor, even windows default cursor should be alright.

ropfoyle
  • 45
  • 5
Lxix69
  • 53
  • 7

0 Answers0