From a838567a4f8f48ac45a062962005dd1c1d73bebf Mon Sep 17 00:00:00 2001 From: lostjared Date: Mon, 19 Mar 2018 11:01:39 -0700 Subject: [PATCH] updated playback --- src/main_window.cpp | 5 +-- src/playback_thread.cpp | 74 ++++++++++++++++++----------------------- src/playback_thread.h | 2 ++ 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/main_window.cpp b/src/main_window.cpp index 8a94c2a..2847b14 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -467,7 +467,7 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re #else ext = ".avi"; #endif - + Log(tr("Capture Device Opened [Camera]\n")); std::ostringstream time_stream; time_stream << "-" << (m->tm_year + 1900) << "." << (m->tm_mon + 1) << "." << m->tm_mday << "_" << m->tm_hour << "." << m->tm_min << "." << m->tm_sec << "_"; stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ext; @@ -549,7 +549,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b int res_h = capture_video.get(CV_CAP_PROP_FRAME_HEIGHT); QString str; QTextStream stream(&str); - stream << "Opened capture device " << res_w << "x" << res_h << "\n"; + stream << "Opened capture device [Video] " << res_w << "x" << res_h << "\n"; stream << "Video File: " << filename << "\n"; stream << "FPS: " << video_fps << "\n"; stream << "Frame Count: " << video_frames << "\n"; @@ -636,6 +636,7 @@ void AC_MainWindow::controls_Stop() { disp->hide(); playback->Release(); } + Log(tr("Capture device [Closed]\n"));; } void AC_MainWindow::controls_ShowVideo() { diff --git a/src/playback_thread.cpp b/src/playback_thread.cpp index e57de95..02df3f2 100644 --- a/src/playback_thread.cpp +++ b/src/playback_thread.cpp @@ -136,6 +136,32 @@ void Playback::setDisplayed(bool shown) { video_shown = shown; } +void Playback::drawEffects(cv::Mat &frame) { + if(ac::set_color_map > 0) ac::ApplyColorMap(frame); + 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_); + } + +} + +void Playback::drawFilter(cv::Mat &frame, std::pair &filter) { + if(filter.first == 0) { + ac::draw_func[filter.second](frame); + } else if(current_filter.first == 1) { + current_filterx = filter.second; + ac::alphaFlame(frame); + } else if(filter.first == 2) { + draw_plugin(frame, filter.second); + } +} + void Playback::run() { int duration = 1000/ac::fps; @@ -155,56 +181,22 @@ void Playback::run() { mutex_shown.unlock(); ac::orig_frame = frame.clone(); if(single_mode == true) { - ac::in_custom = false; - if(current_filter.first == 0) { - ac::draw_func[current_filter.second](frame); - } else if(current_filter.first == 1) { - current_filterx = current_filter.second; - ac::alphaFlame(frame); - } else if(current_filter.first == 2) { - draw_plugin(frame, current_filter.second); - } - msleep(duration/2); mutex.lock(); - if(ac::set_color_map > 0) ac::ApplyColorMap(frame); - 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_); - } + ac::in_custom = false; + drawFilter(frame, current_filter); + msleep(duration/2); + drawEffects(frame); mutex.unlock(); } else if(cur.size()>0) { + mutex.lock(); ac::in_custom = true; for(unsigned int i = 0; i < cur.size(); ++i) { if(i == cur.size()-1) ac::in_custom = false; - if(cur[i].first == 0) { - ac::draw_func[cur[i].second](frame); - } else if(cur[i].first == 1) { - current_filterx = cur[i].second; - ac::alphaFlame(frame); - } else if(cur[i].first == 2) { - draw_plugin(frame, cur[i].second); - } + drawFilter(frame, cur[i]); msleep(duration/2); } - mutex.lock(); - if(ac::set_color_map > 0) ac::ApplyColorMap(frame); - 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_); - } + drawEffects(frame); mutex.unlock(); } else { msleep(duration); diff --git a/src/playback_thread.h b/src/playback_thread.h index 88289cc..8e9503f 100644 --- a/src/playback_thread.h +++ b/src/playback_thread.h @@ -56,6 +56,8 @@ public: void setDisplayed(bool shown); void setIndexChanged(std::string name); void setSingleMode(bool val); + void drawFilter(cv::Mat &frame, std::pair &filter); + void drawEffects(cv::Mat &frame); signals: void procImage(const QImage image); void stopRecording();