I’m new to openCV, and I tested my code using the cv::setTrackbarMax() function with opencv 4.5.4.
Using the Visual C++ (MSVC) debugger, I found that after executing the setTrackbarMax() function, the trackbar in the window was broken and I could not grab the trackbar to change its value.
The same phenomenon can be seen in the tutorial code “samples/cpp/falsecolor.cpp”
https://docs.opencv.org/4.5.3/d2/dcf/samples_2cpp_2falsecolor_8cpp-example.html
The following line in window_w32.cpp seems to cause the error.
return cv::Range(trackbar.minval, trackbar.maxval);
}
void setRange(const cv::Range& range) CV_OVERRIDE
{
auto trackbar_ptr = trackbar_.lock();
CV_Assert(trackbar_ptr);
CvTrackbar& trackbar = *trackbar_ptr;
CV_CheckLE(range.start, range.end, "Invalid trackbar range");
trackbar.minval = range.start;
trackbar.maxval = range.start;
SendMessage(trackbar.hwnd, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)trackbar.minval);
SendMessage(trackbar.hwnd, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)trackbar.maxval);
}
}; // Win32UITrackbar
class Win32BackendUI : public UIBackend
{
public:
~Win32BackendUI() CV_OVERRIDE
In the above, should “range.end” be assigned to trackbar.maxval instead of “range.start”?
Thanks in advance.
2 Likes
berak
November 3, 2021, 4:14pm
2
it very much looks like you have a valid issue here ;}
Thank you for your quick reply! I submitted a new issue based on your suggestion.
opened 04:25PM - 03 Nov 21 UTC
##### System information (version)
- OpenCV => 4.5.4
- Operating System / Plat… form => Windows 64 Bit
- Compiler => Visual Studio 2019
##### Detailed description
I’m new to openCV, and I tested my code using the cv::setTrackbarMax() function with opencv 4.5.4.
Using the Visual C++ (MSVC) debugger, I found that after executing the setTrackbarMax() function, the trackbar in the window was broken and I could not grab the trackbar to change its value.
The same phenomenon can be seen in the tutorial code “samples/cpp/falsecolor.cpp”
https://docs.opencv.org/4.5.3/d2/dcf/samples_2cpp_2falsecolor_8cpp-example.html
The following line in window_w32.cpp seems to cause the error.
https://github.com/opencv/opencv/blob/17234f82d025e3bbfbf611089637e5aa2038e7b8/modules/highgui/src/window_w32.cpp#L2987
In the above, should “range.end” be assigned to trackbar.maxval instead of “range.start”?
Thanks in advance.
##### Steps to reproduce
The same phenomenon can be seen in the tutorial code “samples/cpp/falsecolor.cpp”
https://docs.opencv.org/4.5.3/d2/dcf/samples_2cpp_2falsecolor_8cpp-example.html
(In my environment,
> setTrackbarPos("colormap", winName, -1);
does not work correctly and I commented out the line. )
##### Issue submission checklist
- [x] I report the issue, it's not a question
- [x] I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution
- [x] I updated to latest OpenCV version and the issue is still there
- [x] There is reproducer code and related data files: videos, images, onnx, etc
berak
November 3, 2021, 4:33pm
4
however, i wonder - how did you get there, even ?
(stacktrace or similar ?)
setTrackbarMax() does not call this code, afaik.
In my case, cv::setTrackbarMax() is defined in window.cpp and it calls trackbar->setRange().
{
cv::AutoLock lock(cv::getWindowMutex());
auto window = findWindow_(winName);
if (window)
{
auto trackbar = window->findTrackbar(trackbarName);
CV_Assert(trackbar);
Range old_range = trackbar->getRange();
Range range(std::min(old_range.start, maxval), maxval);
return trackbar->setRange(range);
}
}
#if defined(OPENCV_HIGHGUI_WITHOUT_BUILTIN_BACKEND) && defined(ENABLE_PLUGINS)
auto backend = getCurrentUIBackend();
if (backend)
{
CV_LOG_WARNING(NULL, "Can't find window with name: '" << winName << "'. Do nothing");
CV_NOT_FOUND_DEPRECATION;
}
Does it answer the question?
1 Like
berak
November 3, 2021, 4:55pm
6
apologies, i got it wrong before, setTrackbarMax() != cvSetTrackbarMax()
(looked at the wrong code)
1 Like