Trackbar not fit to window. How to fix?

asked 2019-07-01 08:44:38 -0500

Hordon gravatar image

updated 2019-07-01 08:58:23 -0500

If I create multiple trackbar for one window, for some reason the last one (doesn't matter how much trackbar I have, always the last one) doesn't fit to the window, it's too big. After I manually extend the window and then set back to the original size, the last trackbar fit as it should, the problem is gone.

I create a namedWindow with autosize flag before adding the trackbars. I already tried to resize the window with cv::resizeWindow after adding the trackbars, but it doesn't worked. What could be wrong?

1.) Create window

cv::namedWindow(_windowName, cv::WINDOW_AUTOSIZE);

2.) Create a trackbar with callback (_value.at(0) = 0, maxValue = 25)

cv::createTrackbar(trackbarName, windowName, &_values.at(0), maxValue, trackbarCallback, &_values);

 trackbarCallback1(_values.at(0), &_values);

3.) The callback

void Trackbar::trackbarCallback1(int value, void* values_ptr)
{
    std::vector<int>* values = (std::vector<int>*)values_ptr;
    values->at(0) = value;
    cv::Mat* result = _func_ptr(_imagesInput, _values);
    cv::imshow(_windowName, *result);
}

I use OpenCV 4.0.1 with Xcode 11 beta on macOS Mojave.

image description

edit retag flag offensive close merge delete

Comments

os, opencv version ?

seeing your code might be also helpful.

berak gravatar imageberak ( 2019-07-01 08:50:38 -0500 )edit
1

@berak Edited the question with these informations!

Hordon gravatar imageHordon ( 2019-07-01 08:59:48 -0500 )edit