Large Gap below Trackbars on Windows 10 pushes image off screen

I’m having troubles with the trackbars in OpenCV in Windows 10. I’m trying to fine-tune the parameters in my image processing pipeline. If I only use a few trackbars per function, things look okay, but for more complex functions (such as simpleBlobDetector), there is a large vertical gap which pushes the associated image off my screen (see screenshot).

I realize that I can add a separate window for the image, but when I have many functions in the pipeline, all the open windows become difficult to manage. Is there a way around this vertical gap? I installed OpenCV with ‘pip install opencv-python’. For some reason, it appears to have installed the dev version (version 4.5.4-dev). Not sure if that matters.

Any thoughts or suggestions?

Below is my test code:

# vertical gap below trackbars (ui sliders) on Windows 10
import cv2
import numpy as np
image = cv2.imread("images\\blob.jpg", cv2.IMREAD_GRAYSCALE)
if image is None:
    print('Could not open or find the image.')
    exit(0)
windowName='Detector'
cv2.namedWindow(windowName)
cv2.imshow(windowName, image)
def nothing(x):  
    pass

cv2.createTrackbar('minThresh',windowName,0,255,nothing)
cv2.createTrackbar('maxThresh',windowName,100,255,nothing)
cv2.createTrackbar('threshStep',windowName,10,25,nothing)

cv2.createTrackbar('AREA',windowName,0,1,nothing)
cv2.createTrackbar('minArea',windowName,30,255,nothing)
cv2.createTrackbar('maxArea',windowName,15000,25000,nothing)

cv2.createTrackbar('CIRCLRTY',windowName,0,1,nothing)
cv2.createTrackbar('minCir',windowName,80,100,nothing)

cv2.createTrackbar('CONVEXITY',windowName,0,1,nothing)
cv2.createTrackbar('minCnvxty',windowName,50,100,nothing)

cv2.createTrackbar('minBlbDst',windowName,25,512,nothing)

cv2.waitKey(0)
cv2.destroyAllWindows()

And the “blob” image thanks to: Blob Detection Using OpenCV ( Python, C++ ) |

blob

yes, the highgui code is buggy.

check for existing issues on OpenCV’s github. there probably is one already. if there isn’t one, feel free to create it.

everyone hopes that OpenCV v5 will grow a completely new GUI/graphics module that’ll make all these issues obsolete.

1 Like