1
我想創建一個MENU軌跡條,它改變了用戶想要改變的參數。因此,如果設置爲「1」,BLUR軌跡條會出現,我們可以模糊圖片,如果出現「2」ALPHA和BETA軌跡條,我們可以更改亮度和對比度,但BLUR軌跡條仍然可見,我們可以將模糊更改爲好吧,我希望只有當MENU軌跡欄的值爲1時才能看到它。我試圖用'if','switch'和'while'來做,但它們不起作用。它可能是在擦除其他軌道條件的情況下,但我沒有找到它的功能。或者任何想法如何顯示精確的trackbar?是否可以刪除OpenCV中的trackbar?
下面是代碼(的.cpp)的一部分:
#include <opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
const int slider_max = 100, slider2_max = 100, slider3_max = 100, slider5_max = 2;
int slider = 0, slider2 = 0, slider3 = 0, slider5 = 0;
(...)
void transf(int, void*)
{
(...)
if (slider5 == 0)
{
setTrackbarPos(ALPHA, name3, 0);
setTrackbarPos(BETA, name3, 0);
setTrackbarPos(BLUR, name3, 0);
imshow(name, before);
}
if (slider5 == 1)
{
setTrackbarPos(ALPHA, name3, 0);
setTrackbarPos(BETA, name3, 0);
createTrackbar(BLUR, name3, &slider, slider_max, blur);
blur(0,0);
}
if (slider5 == 2)
{
setTrackbarPos(BLUR, name3, 0);
createTrackbar(ALPHA, name3, &slider2, slider2_max+100, contrBright);
createTrackbar(BETA, name3, &slider3, slider3_max, contrBright);
contrBright(0,0);
}
}
int main()
{
(...)
createTrackbar(MENU, name, &slider5, slider5_max, transf);
transf(0,0);
waitKey(0);
return 0;
}