Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Closed
Description
System Information
OpenCV version: 4.8.0
Operating System / Platform: Win 10
Compiler & compiler version: vs2019 vc16
Detailed description
When you uncomment codesetTrackbarPos("kernel", "dst", 3);, the program will report an error during runtime
#include<opencv2/opencv.hpp>usingnamespacecv;usingnamespacestd;voidgaussianBlurCall(int pos,void* userdata) { Mat* img =static_cast<Mat*>(userdata);int k =getTrackbarPos("kernel","dst");if (k %2 ==0) { k = k -1; }int sigma =getTrackbarPos("sigma","dst"); Mat dst;GaussianBlur(*img, dst,Size(k, k), sigma);imshow("dst", dst);}intmain(int argc,char** argv){ Mat src =imread("blur.tif");namedWindow("dst", WINDOW_NORMAL);createTrackbar("kernel","dst",nullptr,21, gaussianBlurCall, &src);setTrackbarMin("kernel","dst",1);//setTrackbarPos("kernel", "dst", 3);createTrackbar("sigma","dst",nullptr,10, gaussianBlurCall, &src);setTrackbarMin("sigma","dst",1);//setTrackbarPos("sigma", "dst", 7);waitKey();return0;}### Steps to reproduce```cpp#include<opencv2/opencv.hpp>usingnamespacecv;usingnamespacestd;voidgaussianBlurCall(int pos,void* userdata) { Mat* img =static_cast<Mat*>(userdata);int k =getTrackbarPos("kernel","dst");if (k %2 ==0) { k = k -1; }int sigma =getTrackbarPos("sigma","dst"); Mat dst;GaussianBlur(*img, dst,Size(k, k), sigma);imshow("dst", dst);}intmain(int argc,char** argv){ Mat src =imread("blur.tif");namedWindow("dst", WINDOW_NORMAL);createTrackbar("kernel","dst",nullptr,21, gaussianBlurCall, &src);setTrackbarMin("kernel","dst",1);//setTrackbarPos("kernel", "dst", 3); //you can not uncomment this codecreateTrackbar("sigma","dst",nullptr,10, gaussianBlurCall, &src);setTrackbarMin("sigma","dst",1);//setTrackbarPos("sigma", "dst", 7); //you can not uncomment this codewaitKey();return0;}### 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 any solution- [ ] I updated to the latest OpenCV version and the issue is still there- [ ] There is reproducer code and related data files (videos, images, onnx, etc)