如何在 OpenCV 中使用 C++ 添加轨道条?
轨道条是可控制的条,用于控制 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);
}输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP