如何在 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