短视频直播源码,CreateTrackbar亮度和对比度调整
短视频直播源码,CreateTrackbar亮度和对比度调整实现的相关代码
int cv::createTrackbar( const cv::String& trackbarname, 轨迹条名字, const cv::String&winname, 窗口名字, int* value, 滑块初始位置, int count ,滑块达到最大位置的值, cv::TrackbarCallback onChange = (cv::creatTrackbarCallback)0,默认值为0,指向回调函数 void* userdata =(void*) 0 默认值为0,用户传给回调函数的数据值 ); #include<opencv2/opencv.hpp> #include<iostream> using namespace cv; using namespace std; static void on_light(int b, void* usedata) { Mat image = *((Mat*)usedata); Mat out = Mat::zeros(image.size(), image.type()); Mat m = Mat::zeros(image.size(), image.type()); m = Scalar(b, b, b); add(image, m, out); imshow("亮度和对比度调整", out); } static void on_contrast(int b, void* usedata) { Mat image = *((Mat*)usedata); Mat out = Mat::zeros(image.size(), image.type()); Mat m = Mat::zeros(image.size(), image.type()); m = Scalar(b, b, b); double alpha = b / 100.0; addWeighted(image, alpha, m, 0.0, 0.0, out); imshow("亮度和对比度调整", out); } int main(int argc, char** argv) { Mat image = imread("C:/Users/YY/Pictures/Saved Pictures/1.jpg"); int light = 50; int contrast = 100; namedWindow("亮度和对比度调整", WINDOW_AUTOSIZE); createTrackbar("Value", "亮度和对比度调整", &light, 100, on_light,(void*)(&image)); createTrackbar("Contrast", "亮度和对比度调整", &contrast, 200, on_contrast, (void*)(&image)); on_light(50, &image); waitKey(0); destroyAllWindows(); return 0; }
以上就是短视频直播源码,CreateTrackbar亮度和对比度调整实现的相关代码, 更多内容欢迎关注之后的文章