Trackbar not fit to window. How to fix?
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.