트랙 바는 OpenCV에서 다양한 매개변수를 제어하는 데 사용되는 제어 가능한 바입니다. 트랙 바를 사용하여 더 쉽게 만들고 매개변수를 그래픽으로 변경할 수 있습니다. 트랙 바는 이러한 제한을 제거하고 OpenCV를 사용하여 동적 효과를 만들 수 있습니다.
다음 프로그램은 C++를 사용하여 OpenCV에서 트랙바를 추가하는 방법을 보여줍니다.
예시
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main() {
Mat original;//Declaring a matrix//
original = imread("sky.jpg");//loading the image in the matrix//
namedWindow("Slider");//Declaring window to show the image//
int light = 50;//starting value of the trackbar//
createTrackbar("Brightness", "Slider", &light, 100);//creating a trackbar//
int contrast = 50;//starting value of the trackbar//
createTrackbar("Contrast", "Slider", &contrast, 100);//creating a trackbar//
while (true) {
Mat edit;//declaring a matrix//
int Brightness = light - 50;//interaction with trackbar//
double Contrast = contrast / 50.0;//interaction with trackbar//
original.convertTo(edit, -1, Contrast, Brightness);//implement the effect of change of trackbar//
waitKey(50);
}
return(0);
} 출력
