-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added in functionality to record from video file and added in a QMain…
…Window and a main display widget
- Loading branch information
Showing
9 changed files
with
156 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "displaywidget.h" | ||
|
||
DisplayWidget::DisplayWidget(QWidget *parent) : QWidget(parent) | ||
{ | ||
QStringList cameraOptions; | ||
cameraOptions << "0" << "1" << "2" << "3" << "4" << "5" << "6"; | ||
QComboBox* cameraComboBox = new QComboBox; | ||
cameraComboBox->addItems(cameraOptions); | ||
|
||
QHBoxLayout* horizontalLayout = new QHBoxLayout(); | ||
QPushButton *runButton = new QPushButton("run", this); | ||
QPushButton *fileSelector = new QPushButton("select file"); | ||
horizontalLayout->addWidget(cameraComboBox); | ||
horizontalLayout->addWidget(fileSelector); | ||
horizontalLayout->addWidget(runButton); | ||
|
||
QVBoxLayout *layout = new QVBoxLayout; | ||
CVOpenGLWidget* openGLWidget = new CVOpenGLWidget(this); | ||
QRadioButton *sourceSelector = new QRadioButton("Stream from video camera", this); | ||
sourceSelector->setDown(true); | ||
|
||
layout->addWidget(openGLWidget); | ||
layout->addLayout(horizontalLayout); | ||
layout->addWidget(sourceSelector); | ||
|
||
setLayout(layout); | ||
|
||
Camera* camera = new Camera(this); | ||
|
||
QObject::connect(camera, SIGNAL(imageSignal(QImage*)), | ||
openGLWidget, SLOT(ImageSlot(QImage*))); | ||
|
||
// TODO: Add in slot to turn off camera, or something | ||
QObject::connect(runButton, SIGNAL(clicked()), | ||
camera, SLOT(runSlot())); | ||
|
||
QObject::connect(cameraComboBox, SIGNAL(currentIndexChanged(int)), | ||
camera, SLOT(cameraIndexSlot(int))); | ||
|
||
QObject::connect(fileSelector, SIGNAL(clicked()), | ||
this, SLOT(openFileDialog())); | ||
|
||
QObject::connect(sourceSelector, SIGNAL(toggled(bool)), | ||
camera, SLOT(usingVideoCameraSlot(bool))); | ||
|
||
QObject::connect(this, SIGNAL(videoFileNameSignal(QString)), | ||
camera, SLOT(videoFileNameSlot(QString))); | ||
} | ||
|
||
DisplayWidget::~DisplayWidget() | ||
{ | ||
|
||
} | ||
|
||
void DisplayWidget::openFileDialog() | ||
{ | ||
QString filename = QFileDialog::getOpenFileName(this, tr("Video")); | ||
emit videoFileNameSignal(filename); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef DISPLAYWIDGET_H | ||
#define DISPLAYWIDGET_H | ||
|
||
#include <QWidget> | ||
|
||
#include <QObject> | ||
#include <QVBoxLayout> | ||
#include <QPushButton> | ||
#include <QRadioButton> | ||
#include <QComboBox> | ||
#include <QFileDialog> | ||
#include <QFile> | ||
|
||
#include <iostream> | ||
#include <stdio.h> | ||
|
||
#include "CVOpenGLWidget.h" | ||
#include "camera.h" | ||
|
||
class DisplayWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit DisplayWidget(QWidget *parent = 0); | ||
~DisplayWidget(); | ||
|
||
signals: | ||
void videoFileNameSignal(QString videoFileName); | ||
|
||
public slots: | ||
void openFileDialog(); | ||
}; | ||
|
||
#endif // DISPLAYWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,13 @@ | ||
#include <QApplication> | ||
#include <QObject> | ||
#include <QVBoxLayout> | ||
#include <QPushButton> | ||
#include <QComboBox> | ||
|
||
#include <iostream> | ||
#include <stdio.h> | ||
|
||
#include "CVOpenGLWidget.h" | ||
#include "camera.h" | ||
#include "mainwindow.h" | ||
|
||
using namespace std; | ||
|
||
/** @function main */ | ||
int main( int argc, char* argv[] ) | ||
{ | ||
QApplication app(argc, argv); | ||
|
||
QStringList cameraOptions; | ||
cameraOptions << "0" << "1" << "2" << "3" << "4" << "5" << "6"; | ||
QComboBox cameraComboBox; | ||
cameraComboBox.addItems(cameraOptions); | ||
|
||
QHBoxLayout* horizontalLayout = new QHBoxLayout; | ||
horizontalLayout->addWidget(&cameraComboBox); | ||
QPushButton *runButton = new QPushButton("run"); | ||
horizontalLayout->addWidget(runButton); | ||
|
||
QVBoxLayout *layout = new QVBoxLayout; | ||
QWidget layoutWidget; | ||
CVOpenGLWidget openGLWidget(&layoutWidget); | ||
layout->addWidget(&openGLWidget); | ||
layout->addLayout(horizontalLayout); | ||
|
||
layoutWidget.setLayout(layout); | ||
|
||
Camera camera; | ||
QObject::connect(&camera, SIGNAL(imageSignal(QImage*)), | ||
&openGLWidget, SLOT(ImageSlot(QImage*))); | ||
|
||
|
||
// TODO: Add in slot to turn off camera, or something | ||
QObject::connect(runButton, SIGNAL(clicked()), | ||
&camera, SLOT(runSlot())); | ||
|
||
QObject::connect(&cameraComboBox, SIGNAL(currentIndexChanged(int)), | ||
&camera, SLOT(cameraIndexSlot(int))); | ||
layoutWidget.show(); | ||
|
||
MainWindow window; | ||
window.show(); | ||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "mainwindow.h" | ||
|
||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) | ||
{ | ||
DisplayWidget* display = new DisplayWidget(this); | ||
setCentralWidget(display); | ||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
#include "displaywidget.h" | ||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit MainWindow(QWidget *parent = 0); | ||
~MainWindow(); | ||
|
||
signals: | ||
}; | ||
|
||
#endif // MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters