feat(main.py): enhance video display to maximize screen usage and center window
This commit is contained in:
35
main.py
35
main.py
@@ -24,6 +24,10 @@ class MediaGrader:
|
|||||||
FAST_SEEK_MULTIPLIER = 60
|
FAST_SEEK_MULTIPLIER = 60
|
||||||
IMAGE_DISPLAY_DELAY_MS = 100
|
IMAGE_DISPLAY_DELAY_MS = 100
|
||||||
|
|
||||||
|
# Monitor dimensions for full-screen sizing
|
||||||
|
MONITOR_WIDTH = 2560
|
||||||
|
MONITOR_HEIGHT = 1440
|
||||||
|
|
||||||
# Timeline configuration
|
# Timeline configuration
|
||||||
TIMELINE_HEIGHT = 60
|
TIMELINE_HEIGHT = 60
|
||||||
TIMELINE_MARGIN = 20
|
TIMELINE_MARGIN = 20
|
||||||
@@ -121,15 +125,34 @@ class MediaGrader:
|
|||||||
self.thread_pool = ThreadPoolExecutor(max_workers=4)
|
self.thread_pool = ThreadPoolExecutor(max_workers=4)
|
||||||
|
|
||||||
def display_with_aspect_ratio(self, frame):
|
def display_with_aspect_ratio(self, frame):
|
||||||
"""Display frame while maintaining aspect ratio"""
|
"""Display frame while maintaining aspect ratio and maximizing screen usage"""
|
||||||
if frame is None:
|
if frame is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Log frame dimensions
|
# Get frame dimensions
|
||||||
height, width = frame.shape[:2]
|
frame_height, frame_width = frame.shape[:2]
|
||||||
|
|
||||||
# Force window to resize to match the frame dimensions
|
# Calculate aspect ratio
|
||||||
cv2.resizeWindow("Media Grader", width, height)
|
frame_aspect_ratio = frame_width / frame_height
|
||||||
|
monitor_aspect_ratio = self.MONITOR_WIDTH / self.MONITOR_HEIGHT
|
||||||
|
|
||||||
|
# Determine if frame is vertical or horizontal relative to monitor
|
||||||
|
if frame_aspect_ratio < monitor_aspect_ratio:
|
||||||
|
# Frame is more vertical than monitor - maximize height
|
||||||
|
display_height = self.MONITOR_HEIGHT
|
||||||
|
display_width = int(display_height * frame_aspect_ratio)
|
||||||
|
else:
|
||||||
|
# Frame is more horizontal than monitor - maximize width
|
||||||
|
display_width = self.MONITOR_WIDTH
|
||||||
|
display_height = int(display_width / frame_aspect_ratio)
|
||||||
|
|
||||||
|
# Resize window to calculated dimensions
|
||||||
|
cv2.resizeWindow("Media Grader", display_width, display_height)
|
||||||
|
|
||||||
|
# Center the window on screen
|
||||||
|
x_position = (self.MONITOR_WIDTH - display_width) // 2
|
||||||
|
y_position = (self.MONITOR_HEIGHT - display_height) // 2
|
||||||
|
cv2.moveWindow("Media Grader", x_position, y_position)
|
||||||
|
|
||||||
# Display the frame
|
# Display the frame
|
||||||
cv2.imshow("Media Grader", frame)
|
cv2.imshow("Media Grader", frame)
|
||||||
@@ -1446,7 +1469,7 @@ class MediaGrader:
|
|||||||
cv2.namedWindow("Media Grader", cv2.WINDOW_NORMAL)
|
cv2.namedWindow("Media Grader", cv2.WINDOW_NORMAL)
|
||||||
cv2.setMouseCallback("Media Grader", self.mouse_callback)
|
cv2.setMouseCallback("Media Grader", self.mouse_callback)
|
||||||
|
|
||||||
# Set initial window size to a reasonable default
|
# Set initial window size to a reasonable default (will be resized on first frame)
|
||||||
cv2.resizeWindow("Media Grader", 1280, 720)
|
cv2.resizeWindow("Media Grader", 1280, 720)
|
||||||
|
|
||||||
while self.media_files and self.current_index < len(self.media_files):
|
while self.media_files and self.current_index < len(self.media_files):
|
||||||
|
Reference in New Issue
Block a user