mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-18 12:50:07 +01:00
added single filter mode to playback, still need to implement fade
This commit is contained in:
@@ -96,7 +96,7 @@ void AC_MainWindow::createControls() {
|
||||
filters = new QComboBox(this);
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -115,12 +115,14 @@ void AC_MainWindow::createControls() {
|
||||
|
||||
filter_single = new QRadioButton(tr("Single Filter"), this);
|
||||
filter_single->setGeometry(30, 40, 100, 15);
|
||||
|
||||
filter_custom = new QRadioButton(tr("Custom Filter"), this);
|
||||
filter_custom->setGeometry(30, 65, 100, 15);
|
||||
|
||||
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_remove = new QPushButton(tr("Remove"), this);
|
||||
btn_moveup = new QPushButton(tr("Move Up"), this);
|
||||
@@ -335,12 +337,25 @@ void AC_MainWindow::colorChanged(int) {
|
||||
|
||||
void AC_MainWindow::colorMapChanged(int 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() {
|
||||
int row = filters->currentIndex();
|
||||
@@ -535,6 +550,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
|
||||
QString str;
|
||||
QTextStream stream(&str);
|
||||
stream << "Opened capture device " << res_w << "x" << res_h << "\n";
|
||||
stream << "Video File: " << filename << "\n";
|
||||
stream << "FPS: " << video_fps << "\n";
|
||||
stream << "Frame Count: " << video_frames << "\n";
|
||||
output_directory = outdir;
|
||||
@@ -552,14 +568,12 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
|
||||
time_t t = time(0);
|
||||
struct tm *m;
|
||||
m = localtime(&t);
|
||||
|
||||
QString ext;
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
ext = (type == 0) ? ".mov" : ".avi";
|
||||
#else
|
||||
ext = ".avi";
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
@@ -58,6 +58,8 @@ public slots:
|
||||
void colorChanged(int pos);
|
||||
void colorMapChanged(int pos);
|
||||
void comboFilterChanged(int pos);
|
||||
void setFilterSingle();
|
||||
void setFilterCustom();
|
||||
private:
|
||||
void createControls();
|
||||
void createMenu();
|
||||
|
||||
@@ -13,7 +13,6 @@ Playback::Playback(QObject *parent) : QThread(parent) {
|
||||
isPaused = false;
|
||||
bright_ = gamma_ = saturation_ = 0;
|
||||
single_mode = true;
|
||||
current_filter = 0;
|
||||
}
|
||||
|
||||
void Playback::Play() {
|
||||
@@ -111,8 +110,8 @@ void Playback::setColorOptions(int b, int g, int s) {
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void Playback::setIndexChanged(int pos) {
|
||||
current_filter = pos;
|
||||
void Playback::setIndexChanged(std::string value) {
|
||||
current_filter = filter_map[value];
|
||||
}
|
||||
|
||||
void Playback::setSingleMode(bool val) {
|
||||
@@ -155,7 +154,31 @@ void Playback::run() {
|
||||
cur = current;
|
||||
mutex_shown.unlock();
|
||||
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;
|
||||
for(unsigned int i = 0; i < cur.size(); ++i) {
|
||||
if(i == cur.size()-1)
|
||||
|
||||
@@ -34,7 +34,7 @@ private:
|
||||
unsigned int red, green, blue;
|
||||
unsigned int bright_, gamma_, saturation_;
|
||||
bool single_mode;
|
||||
int current_filter;
|
||||
std::pair<int, int> current_filter;
|
||||
public:
|
||||
Playback(QObject *parent = 0);
|
||||
~Playback();
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void setImage(const cv::Mat &image);
|
||||
void setStep();
|
||||
void setDisplayed(bool shown);
|
||||
void setIndexChanged(int pos);
|
||||
void setIndexChanged(std::string name);
|
||||
void setSingleMode(bool val);
|
||||
signals:
|
||||
void procImage(const QImage image);
|
||||
|
||||
@@ -45,5 +45,5 @@
|
||||
|
||||
void init_plugins();
|
||||
void draw_plugin(cv::Mat &frame, int filter);
|
||||
|
||||
extern std::unordered_map<std::string, std::pair<int, int>> filter_map;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user