Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Can not set trackBarPos, if two trackbar in the same window #25537

Closed
@RichardZeenChen

Description

@RichardZeenChen

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp