updated added option of using mov/avi on Linux/OSX

This commit is contained in:
lostjared
2017-02-21 12:48:22 -08:00
parent d7fa2bdbfa
commit 273b9bd284
4 changed files with 47 additions and 15 deletions

View File

@@ -293,7 +293,7 @@ void AC_MainWindow::Log(const QString &s) {
log_text->setTextCursor(tmpCursor); log_text->setTextCursor(tmpCursor);
} }
bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool record) { bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool record, int type) {
programMode = MODE_CAMERA; programMode = MODE_CAMERA;
progress_bar->hide(); progress_bar->hide();
controls_showvideo->setEnabled(false); controls_showvideo->setEnabled(false);
@@ -333,7 +333,7 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
m = localtime(&t); m = localtime(&t);
QString ext; QString ext;
#if defined(__APPLE__) || defined(__linux__) #if defined(__APPLE__) || defined(__linux__)
ext = ".mov"; ext = (type == 0) ? ".mov" : ".avi";
#else #else
ext = ".avi"; ext = ".avi";
#endif #endif
@@ -362,6 +362,8 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
QMessageBox::information(this, tr("Info"), tr("Could not set resolution reverting to default ..")); QMessageBox::information(this, tr("Info"), tr("Could not set resolution reverting to default .."));
res_w = ores_w; res_w = ores_w;
res_h = ores_h; res_h = ores_h;
capture_camera.set(CV_CAP_PROP_FRAME_WIDTH, res_w);
capture_camera.set(CV_CAP_PROP_FRAME_HEIGHT, res_h);
} }
QString res_str; QString res_str;
@@ -371,8 +373,7 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
if(recording) { if(recording) {
video_file_name = output_name; video_file_name = output_name;
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
writer = cv::VideoWriter(output_name.toStdString(), CV_FOURCC('M', 'P', '4', 'V') writer = cv::VideoWriter(output_name.toStdString(), (type == 0) ? CV_FOURCC('M', 'P', '4', 'V') : CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true);
/*CV_FOURCC('X','V','I','D')*/, video_fps, cv::Size(res_w, res_h), true);
#else #else
writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true);
#endif #endif
@@ -394,7 +395,7 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
return true; return true;
} }
bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, bool record) { bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, bool record, int type) {
programMode = MODE_VIDEO; programMode = MODE_VIDEO;
controls_stop->setEnabled(true); controls_stop->setEnabled(true);
controls_pause->setEnabled(true); controls_pause->setEnabled(true);
@@ -439,7 +440,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
QString ext; QString ext;
#if defined(__APPLE__) || defined(__linux__) #if defined(__APPLE__) || defined(__linux__)
ext = ".mov"; ext = (type == 0) ? ".mov" : ".avi";
#else #else
ext = ".avi"; ext = ".avi";
#endif #endif
@@ -452,7 +453,7 @@ bool AC_MainWindow::startVideo(const QString &filename, const QString &outdir, b
if(recording) { if(recording) {
video_file_name = output_name; video_file_name = output_name;
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
writer = cv::VideoWriter(output_name.toStdString(), /*CV_FOURCC('X','V','I','D')*/ CV_FOURCC('M', 'P', '4', 'V'), video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), (type == 0) ? CV_FOURCC('M', 'P', '4', 'V') : CV_FOURCC('X','V','I','D'), video_fps, cv::Size(res_w, res_h), true);
#else #else
writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true); writer = cv::VideoWriter(output_name.toStdString(), -1, video_fps, cv::Size(res_w, res_h), true);
#endif #endif

View File

@@ -14,8 +14,8 @@ public:
AC_MainWindow(QWidget *parent = 0); AC_MainWindow(QWidget *parent = 0);
~AC_MainWindow(); ~AC_MainWindow();
void Log(const QString &s); void Log(const QString &s);
bool startCamera(int res, int dev, const QString &outdir, bool record); bool startCamera(int res, int dev, const QString &outdir, bool record, int type);
bool startVideo(const QString &filename, const QString &outdir, bool record); bool startVideo(const QString &filename, const QString &outdir, bool record, int type);
QListWidget *filters, *custom_filters; QListWidget *filters, *custom_filters;
QPushButton *btn_add, *btn_remove, *btn_moveup, *btn_movedown; QPushButton *btn_add, *btn_remove, *btn_moveup, *btn_movedown;
QTextEdit *log_text; QTextEdit *log_text;

View File

@@ -34,11 +34,19 @@ void CaptureCamera::createControls() {
output_dir->setGeometry(110, 65, 175, 20); output_dir->setGeometry(110, 65, 175, 20);
output_dir->setReadOnly(true); output_dir->setReadOnly(true);
chk_record = new QCheckBox(tr("Record"), this); chk_record = new QCheckBox(tr("Record"), this);
chk_record->setGeometry(10, 95, 100, 20); chk_record->setGeometry(10, 95, 70, 20);
btn_start = new QPushButton(tr("Start"), this); btn_start = new QPushButton(tr("Start"), this);
btn_start->setGeometry(185, 95, 100, 20); btn_start->setGeometry(185, 95, 100, 20);
connect(btn_start, SIGNAL(clicked()), this, SLOT(btn_Start())); connect(btn_start, SIGNAL(clicked()), this, SLOT(btn_Start()));
connect(btn_select, SIGNAL(clicked()), this, SLOT(btn_Select())); connect(btn_select, SIGNAL(clicked()), this, SLOT(btn_Select()));
#if defined(__APPLE__) || defined(__linux__)
video_type = new QComboBox(this);
video_type->setGeometry(80, 90, 90, 25);
video_type->addItem("MOV");
video_type->addItem("AVI");
#endif
} }
void CaptureCamera::setParent(AC_MainWindow *p) { void CaptureCamera::setParent(AC_MainWindow *p) {
@@ -55,8 +63,16 @@ void CaptureCamera::btn_Select() {
} }
void CaptureCamera::btn_Start() { void CaptureCamera::btn_Start() {
int vtype;
#if defined(__APPLE__) || defined(__linux__)
vtype = video_type->currentIndex();
#else
vtype = 1;
#endif
if(output_dir->text().length() > 0) { if(output_dir->text().length() > 0) {
if(win_parent->startCamera(combo_res->currentIndex(), combo_device->currentIndex(), output_dir->text(), chk_record->isChecked())) { if(win_parent->startCamera(combo_res->currentIndex(), combo_device->currentIndex(), output_dir->text(), chk_record->isChecked(), vtype)) {
hide(); hide();
} else { } else {
@@ -89,7 +105,14 @@ void CaptureVideo::createControls() {
btn_start = new QPushButton(tr("Start"), this); btn_start = new QPushButton(tr("Start"), this);
btn_start->setGeometry(10, 60, 100, 20); btn_start->setGeometry(10, 60, 100, 20);
chk_record = new QCheckBox(tr("Record"), this); chk_record = new QCheckBox(tr("Record"), this);
chk_record->setGeometry(110, 60, 100, 20); chk_record->setGeometry(110, 60, 80, 20);
#if defined(__APPLE__) || defined(__linux__)
video_type = new QComboBox(this);
video_type->setGeometry(180, 55, 120, 25);
video_type->addItem("MOV");
video_type->addItem("AVI");
#endif
connect(btn_setedit, SIGNAL(clicked()), this, SLOT(btn_SetSourceFile())); connect(btn_setedit, SIGNAL(clicked()), this, SLOT(btn_SetSourceFile()));
connect(btn_setout, SIGNAL(clicked()), this, SLOT(btn_SetOutputDir())); connect(btn_setout, SIGNAL(clicked()), this, SLOT(btn_SetOutputDir()));
@@ -122,7 +145,14 @@ void CaptureVideo::btn_Start() {
return; return;
} }
if(win_parent->startVideo(edit_src->text(), edit_outdir->text(), chk_record->isChecked())) { int num;
#if defined(__APPLE__) || defined(__linux__)
num = video_type->currentIndex();
#else
num = 1;
#endif
if(win_parent->startVideo(edit_src->text(), edit_outdir->text(), chk_record->isChecked(), num)) {
hide(); hide();
} else { } else {
QMessageBox::information(this, tr("Could not open file"), tr("Could not open video file, an error has occured")); QMessageBox::information(this, tr("Could not open file"), tr("Could not open video file, an error has occured"));

View File

@@ -16,8 +16,7 @@ public:
QLineEdit *output_dir; QLineEdit *output_dir;
QCheckBox *chk_record; QCheckBox *chk_record;
QPushButton *btn_start, *btn_select; QPushButton *btn_start, *btn_select;
QComboBox *video_type;
public slots: public slots:
void btn_Select(); void btn_Select();
void btn_Start(); void btn_Start();
@@ -36,6 +35,8 @@ public:
QLineEdit *edit_src, *edit_outdir; QLineEdit *edit_src, *edit_outdir;
QPushButton *btn_setedit, *btn_setout, *btn_start; QPushButton *btn_setedit, *btn_setout, *btn_start;
QCheckBox *chk_record; QCheckBox *chk_record;
QComboBox *video_type;
public slots: public slots:
void btn_SetSourceFile(); void btn_SetSourceFile();
void btn_SetOutputDir(); void btn_SetOutputDir();