Skip to content

Commit

Permalink
fixed file name, added select image
Browse files Browse the repository at this point in the history
  • Loading branch information
lostjared committed Feb 5, 2017
1 parent 2256d9b commit 59d5eff
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
33 changes: 28 additions & 5 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void custom_filter(cv::Mat &frame) {

AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
generate_map();
setGeometry(0, 0, 800, 600);
setGeometry(100, 100, 800, 600);
setFixedSize(800, 600);
setWindowTitle("Acid Cam v2 - Qt");
createControls();
Expand Down Expand Up @@ -137,21 +137,26 @@ void AC_MainWindow::createMenu() {
controls_stop->setEnabled(false);

controls_snapshot = new QAction(tr("Take &Snapshot"), this);
controls_snapshot->setShortcut(tr("Ctrl+S"));
controls_snapshot->setShortcut(tr("S"));
controls_menu->addAction(controls_snapshot);

controls_pause = new QAction(tr("&Pause"), this);
controls_pause->setShortcut(tr("Ctrl+P"));
controls_pause->setShortcut(tr("P"));
controls_menu->addAction(controls_pause);

controls_step = new QAction(tr("Step"), this);
controls_step->setShortcut(tr("Controls+I"));
controls_step->setShortcut(tr("I"));
controls_menu->addAction(controls_step);

controls_setimage = new QAction(tr("Set Image"), this);
controls_setimage->setShortcut(tr("Ctrl+I"));
controls_menu->addAction(controls_setimage);

connect(controls_snapshot, SIGNAL(triggered()), this, SLOT(controls_Snap()));
connect(controls_pause, SIGNAL(triggered()), this, SLOT(controls_Pause()));
connect(controls_step, SIGNAL(triggered()), this, SLOT(controls_Step()));
connect(controls_stop, SIGNAL(triggered()), this, SLOT(controls_Stop()));
connect(controls_setimage, SIGNAL(triggered()), this, SLOT(controls_SetImage()));

controls_pause->setCheckable(true);
controls_pause->setText("Pause");
Expand Down Expand Up @@ -328,7 +333,14 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
QString output_name;
QTextStream stream_(&output_name);
static unsigned int index = 0;
stream_ << outdir << "/" << "AC2.Output." << ++index << ".avi";
time_t t = time(0);
struct tm *m;
m = localtime(&t);
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) << ".avi";


if(recording) {
video_file_name = output_name;
#if defined(__linux__) || defined(__APPLE__)
Expand Down Expand Up @@ -416,6 +428,17 @@ void AC_MainWindow::controls_Pause() {
}
}

void AC_MainWindow::controls_SetImage() {
QString fileName = QFileDialog::getOpenFileName(this,tr("Open Image"), "/home", tr("Image Files (*.png *.jpg)"));
if(fileName != "") {
blend_image = cv::imread(fileName.toStdString());
if(!blend_image.empty()) {
blend_set = true;
QMessageBox::information(this, tr("Loaded Image"), tr("Image set"));
}
}
}

void AC_MainWindow::controls_Step() {
step_frame = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AC_MainWindow : public QMainWindow {
QComboBox *combo_rgb;
QMenu *file_menu, *controls_menu, *help_menu;
QAction *file_exit, *file_new_capture, *file_new_video;
QAction *controls_snapshot, *controls_pause, *controls_step, *controls_stop;
QAction *controls_snapshot, *controls_pause, *controls_step, *controls_stop, *controls_setimage;
QAction *help_about;
public slots:
void addClicked();
Expand All @@ -32,6 +32,7 @@ public slots:
void controls_Snap();
void controls_Pause();
void controls_Step();
void controls_SetImage();
void help_About();
void timer_Camera();
void timer_Video();
Expand Down
2 changes: 2 additions & 0 deletions src/new_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


CaptureCamera::CaptureCamera(QWidget *parent) : QDialog(parent) {
setGeometry(100, 100, 290, 120);
setFixedSize(290, 120);
setWindowTitle("Capture from Webcam");
setWindowIcon(QPixmap(":/images/icon.png"));
Expand Down Expand Up @@ -67,6 +68,7 @@ void CaptureCamera::btn_Start() {
}

CaptureVideo::CaptureVideo(QWidget *parent) : QDialog(parent) {
setGeometry(100, 100, 330, 100);
setFixedSize(330, 100);
setWindowTitle(("Capture from Video"));
setWindowIcon(QPixmap(":/images/icon.png"));
Expand Down

0 comments on commit 59d5eff

Please sign in to comment.