added single filter mode to playback, still need to implement fade

This commit is contained in:
lostjared
2018-03-18 20:10:30 -07:00
parent 41c3f9bc3e
commit 74876ebc43
5 changed files with 53 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ void AC_MainWindow::createControls() {
filters = new QComboBox(this); filters = new QComboBox(this);
filters->setGeometry(10, 105, 380, 30); filters->setGeometry(10, 105, 380, 30);
for(int i = 0; i < ac::draw_max-4; ++i) { for(int i = 0; i < ac::draw_max-5; ++i) {
filters->addItem(ac::draw_strings[i].c_str()); filters->addItem(ac::draw_strings[i].c_str());
} }
@@ -115,12 +115,14 @@ void AC_MainWindow::createControls() {
filter_single = new QRadioButton(tr("Single Filter"), this); filter_single = new QRadioButton(tr("Single Filter"), this);
filter_single->setGeometry(30, 40, 100, 15); filter_single->setGeometry(30, 40, 100, 15);
filter_custom = new QRadioButton(tr("Custom Filter"), this); filter_custom = new QRadioButton(tr("Custom Filter"), this);
filter_custom->setGeometry(30, 65, 100, 15); filter_custom->setGeometry(30, 65, 100, 15);
filter_single->setChecked(true); filter_single->setChecked(true);
connect(filter_single, SIGNAL(pressed()), this, SLOT(setFilterSingle()));
connect(filter_custom, SIGNAL(pressed()), this, SLOT(setFilterCustom()));
btn_add = new QPushButton(tr("Add"), this); btn_add = new QPushButton(tr("Add"), this);
btn_remove = new QPushButton(tr("Remove"), this); btn_remove = new QPushButton(tr("Remove"), this);
btn_moveup = new QPushButton(tr("Move Up"), this); btn_moveup = new QPushButton(tr("Move Up"), this);
@@ -335,12 +337,25 @@ void AC_MainWindow::colorChanged(int) {
void AC_MainWindow::colorMapChanged(int pos) { void AC_MainWindow::colorMapChanged(int pos) {
playback->setColorMap(pos); playback->setColorMap(pos);
Log("Changed Color Map\n");
} }
void AC_MainWindow::comboFilterChanged(int pos) { void AC_MainWindow::comboFilterChanged(int) {
playback->setIndexChanged(filters->currentText().toStdString());
QString str;
QTextStream stream(&str);
stream << "Filter changed to: " << filters->currentText() << "\n";
Log(str);
} }
void AC_MainWindow::setFilterSingle() {
playback->setSingleMode(true);
Log("Set to Single Filter Mode\n");
}
void AC_MainWindow::setFilterCustom() {
playback->setSingleMode(false);
Log("Set to Custom Filter Mode\n");
}
void AC_MainWindow::addClicked() { void AC_MainWindow::addClicked() {
int row = filters->currentIndex(); int row = filters->currentIndex();
@@ -535,6 +550,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
QString str; QString str;
QTextStream stream(&str); QTextStream stream(&str);
stream << "Opened capture device " << res_w << "x" << res_h << "\n"; stream << "Opened capture device " << res_w << "x" << res_h << "\n";
stream << "Video File: " << filename << "\n";
stream << "FPS: " << video_fps << "\n"; stream << "FPS: " << video_fps << "\n";
stream << "Frame Count: " << video_frames << "\n"; stream << "Frame Count: " << video_frames << "\n";
output_directory = outdir; output_directory = outdir;
@@ -552,14 +568,12 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
time_t t = time(0); time_t t = time(0);
struct tm *m; struct tm *m;
m = localtime(&t); m = localtime(&t);
QString ext; QString ext;
#if defined(__APPLE__) || defined(__linux__) #if defined(__APPLE__) || defined(__linux__)
ext = (type == 0) ? ".mov" : ".avi"; ext = (type == 0) ? ".mov" : ".avi";
#else #else
ext = ".avi"; ext = ".avi";
#endif #endif
std::ostringstream time_stream; 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 << "_"; 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; stream_ << outdir << "/" << "Video." << time_stream.str().c_str() << "AC2.Output." << (++index) << ext;

View File

@@ -58,6 +58,8 @@ public slots:
void colorChanged(int pos); void colorChanged(int pos);
void colorMapChanged(int pos); void colorMapChanged(int pos);
void comboFilterChanged(int pos); void comboFilterChanged(int pos);
void setFilterSingle();
void setFilterCustom();
private: private:
void createControls(); void createControls();
void createMenu(); void createMenu();

View File

@@ -13,7 +13,6 @@ Playback::Playback(QObject *parent) : QThread(parent) {
isPaused = false; isPaused = false;
bright_ = gamma_ = saturation_ = 0; bright_ = gamma_ = saturation_ = 0;
single_mode = true; single_mode = true;
current_filter = 0;
} }
void Playback::Play() { void Playback::Play() {
@@ -111,8 +110,8 @@ void Playback::setColorOptions(int b, int g, int s) {
mutex.unlock(); mutex.unlock();
} }
void Playback::setIndexChanged(int pos) { void Playback::setIndexChanged(std::string value) {
current_filter = pos; current_filter = filter_map[value];
} }
void Playback::setSingleMode(bool val) { void Playback::setSingleMode(bool val) {
@@ -155,7 +154,31 @@ void Playback::run() {
cur = current; cur = current;
mutex_shown.unlock(); mutex_shown.unlock();
ac::orig_frame = frame.clone(); ac::orig_frame = frame.clone();
if(cur.size()>0) { 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_);
}
mutex.unlock();
} else if(cur.size()>0) {
ac::in_custom = true; ac::in_custom = true;
for(unsigned int i = 0; i < cur.size(); ++i) { for(unsigned int i = 0; i < cur.size(); ++i) {
if(i == cur.size()-1) if(i == cur.size()-1)

View File

@@ -34,7 +34,7 @@ private:
unsigned int red, green, blue; unsigned int red, green, blue;
unsigned int bright_, gamma_, saturation_; unsigned int bright_, gamma_, saturation_;
bool single_mode; bool single_mode;
int current_filter; std::pair<int, int> current_filter;
public: public:
Playback(QObject *parent = 0); Playback(QObject *parent = 0);
~Playback(); ~Playback();
@@ -54,7 +54,7 @@ public:
void setImage(const cv::Mat &image); void setImage(const cv::Mat &image);
void setStep(); void setStep();
void setDisplayed(bool shown); void setDisplayed(bool shown);
void setIndexChanged(int pos); void setIndexChanged(std::string name);
void setSingleMode(bool val); void setSingleMode(bool val);
signals: signals:
void procImage(const QImage image); void procImage(const QImage image);

View File

@@ -45,5 +45,5 @@
void init_plugins(); void init_plugins();
void draw_plugin(cv::Mat &frame, int filter); void draw_plugin(cv::Mat &frame, int filter);
extern std::unordered_map<std::string, std::pair<int, int>> filter_map;
#endif #endif