OpenCV imshow and trackbar not responding


I’ve been using OpenCV for a while, but I tried creating a new project with windows 11 and I seem to be having some issues with methods imshow and trackbar.

Im show issue
It does open and update the frame, after 10 seconds give or take if I dont focus the window, also I get a Application not responding when focusing the window, eventually the window goes all white but if I minimize the window it updates again, only being able to look at the window hovering the app on my taskbar.

Task bar
I have a similar issue with the task bar, I can’t open the window without getting a Application not respondingerror, so I can’t interact with the GUI.

Assume I have a loop calling open_visualizer() like this:

while True:

    if cv.waitKey(1) == ord("q"):
import pyautogui
import numpy as np
import cv2 as cv
import mss

def screenshot(left=0, top=0):
    w, h = pyautogui.size()
    stc = mss.mss()
    scr = stc.grab(
            "left": left,
            "top": top,
            "width": w,
            "height": h,

    img = np.array(scr)
    img = cv.cvtColor(img, cv.IMREAD_COLOR)

    return img

def open_visualizer(window_name="Visualizer"):
    scene = screenshot()
    cv.imshow(window_name, scene)