From a6dd1c70bc6dba576a691479e69c984a2f368b2f Mon Sep 17 00:00:00 2001 From: lostjared Date: Sat, 17 Mar 2018 12:41:34 -0700 Subject: [PATCH] added brightness,gamma,saturation sliders and apply in playback thread --- src/main_window.cpp | 33 +++++++++++++++++++++++++++++++++ src/main_window.h | 1 + src/playback_thread.cpp | 19 +++++++++++++++++++ src/playback_thread.h | 2 ++ 4 files changed, 55 insertions(+) diff --git a/src/main_window.cpp b/src/main_window.cpp index c914a21..fcd4881 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -150,6 +150,35 @@ void AC_MainWindow::createControls() { connect(slide_g, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); connect(slide_b, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); + QLabel *label_slide_bright = new QLabel("Brightness: ", this); + label_slide_bright->setGeometry(10, 280, 75, 20); + slide_bright = new QSlider(Qt::Horizontal, this); + slide_bright->setGeometry(80, 275, 100, 30); + slide_bright->setMaximum(255); + slide_bright->setMinimum(0); + slide_bright->setTickInterval(0); + + + QLabel *label_slide_gamma = new QLabel("Gamma: ", this); + label_slide_gamma->setGeometry(190, 280, 65, 20); + slide_gamma = new QSlider(Qt::Horizontal, this); + slide_gamma->setGeometry(245, 275, 100, 30); + slide_gamma->setMaximum(255); + slide_gamma->setMinimum(0); + slide_gamma->setTickInterval(0); + + QLabel *label_sat = new QLabel("Saturation: ", this); + label_sat->setGeometry(350, 280, 100, 20); + slide_saturation = new QSlider(Qt::Horizontal, this); + slide_saturation->setGeometry(420, 275, 100, 30); + slide_saturation->setMaximum(255); + slide_saturation->setMinimum(0); + slide_saturation->setTickInterval(0); + + connect(slide_bright, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + connect(slide_gamma, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + connect(slide_saturation, SIGNAL(valueChanged(int)), this, SLOT(colorChanged(int))); + log_text = new QTextEdit(this); log_text->setGeometry(10, 450, 780,310); log_text->setReadOnly(true); @@ -266,6 +295,10 @@ void AC_MainWindow::slideChanged(int) { playback->setRGB(slide_r->sliderPosition(), slide_g->sliderPosition(), slide_b->sliderPosition()); } +void AC_MainWindow::colorChanged(int) { + playback->setColorOptions(slide_bright->sliderPosition(), slide_gamma->sliderPosition(), slide_saturation->sliderPosition()); +} + void AC_MainWindow::addClicked() { int row = filters->currentRow(); if(row != -1) { diff --git a/src/main_window.h b/src/main_window.h index 1a613e8..aa100c9 100644 --- a/src/main_window.h +++ b/src/main_window.h @@ -53,6 +53,7 @@ public slots: void cb_SetIndex(int index); void frameInc(); void slideChanged(int pos); + void colorChanged(int pos); private: void createControls(); void createMenu(); diff --git a/src/playback_thread.cpp b/src/playback_thread.cpp index 524d1a2..9931ded 100644 --- a/src/playback_thread.cpp +++ b/src/playback_thread.cpp @@ -11,6 +11,7 @@ Playback::Playback(QObject *parent) : QThread(parent) { stop = true; isStep = false; isPaused = false; + bright_ = gamma_ = saturation_ = 0; } void Playback::Play() { @@ -100,6 +101,14 @@ void Playback::setOptions(bool n, int c) { mutex.unlock(); } +void Playback::setColorOptions(int b, int g, int s) { + mutex.lock(); + bright_ = b; + gamma_ = g; + saturation_ = s; + mutex.unlock(); +} + void Playback::setRGB(int r, int g, int b) { mutex.lock(); ac::swapColor_r = r; @@ -146,6 +155,16 @@ void Playback::run() { } else if(cur[i].first == 2) { draw_plugin(frame, cur[i].second); } + if(bright_ > 0) { + ac::setBrightness(frame, 1.0, bright_); + } + if(gamma_ > 0) { + cv::Mat gam = frame.clone(); + ac::setGamma(gam, frame, gamma_); + } + if(saturation_ > 0) { + ac::setSaturation(frame, saturation_); + } } } else { msleep(duration); diff --git a/src/playback_thread.h b/src/playback_thread.h index 0089a83..10731bc 100644 --- a/src/playback_thread.h +++ b/src/playback_thread.h @@ -32,10 +32,12 @@ private: VideoMode mode; int device_num; unsigned int red, green, blue; + unsigned int bright_, gamma_, saturation_; public: Playback(QObject *parent = 0); ~Playback(); void setRGB(int r, int g, int b); + void setColorOptions(int b, int g, int s); void Play(); void Stop(); void Release();