0

My CV2 slider keeps starting with the value "None", but I need it to be an int instandly. The error code I'm getting is this: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

The solution I tried is as follows:

def on_change(value):
    pass

windowname = 'settings'  

cv2.imshow(windowname, 0)
fovx = cv2.createTrackbar('fov x', windowname, int(640), int(1920), on_change)
fovy = cv2.createTrackbar('fov y', windowname, int(640), int(1080), on_change)

while True:
    with mss() as sct:
                
        dimensions = sct.monitors[1] 
        WINDOW_SIZEX = fovx
        WINDOW_SIZEY = fovy
        
        
        monitor = {"top": int((dimensions['height'] / 2) - (int(WINDOW_SIZEY) / 2)), "left": int((dimensions['width'] / 2) - (int(WINDOW_SIZEX) / 2)), "width": int(WINDOW_SIZEX), "height": int(WINDOW_SIZEY)}
joergttv
  • 1
  • 2
  • `fovx = cv2.createTrackbar(...)` That function doesn't return anything, therefore it returns `None` by default, therefore `fovx` is None, therefore `WINDOW_SIZEX` is None, which is why you're getting that error. – John Gordon Jul 19 '23 at 21:52
  • Also, why `int(640)`? 640 is already an integer. Calling `int()` on it is useless. – John Gordon Jul 19 '23 at 21:57

0 Answers0