updated refresh rate (each second)
Fixed not connected signals/slots git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@40 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
13f493aa5c
commit
b1b769ec78
@ -26,7 +26,8 @@
|
|||||||
// Camera ownership transferred
|
// Camera ownership transferred
|
||||||
MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
camera_(camera)
|
camera_(camera),
|
||||||
|
lowestRefreshRate_(99)
|
||||||
{
|
{
|
||||||
ui_ = new Ui_mainWindow();
|
ui_ = new Ui_mainWindow();
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
@ -63,11 +64,13 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
connect(ui_->actionAdd_object, SIGNAL(triggered()), this, SLOT(addObject()));
|
connect(ui_->actionAdd_object, SIGNAL(triggered()), this, SLOT(addObject()));
|
||||||
connect(ui_->actionStart_camera, SIGNAL(triggered()), this, SLOT(startCamera()));
|
connect(ui_->actionStart_camera, SIGNAL(triggered()), this, SLOT(startProcessing()));
|
||||||
connect(ui_->actionStop_camera, SIGNAL(triggered()), this, SLOT(stopProcessing()));
|
connect(ui_->actionStop_camera, SIGNAL(triggered()), this, SLOT(stopProcessing()));
|
||||||
connect(ui_->actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
connect(ui_->actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects()));
|
connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects()));
|
||||||
connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects()));
|
connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects()));
|
||||||
|
|
||||||
|
startProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -162,12 +165,13 @@ void MainWindow::removeObject(ObjWidget * object)
|
|||||||
|
|
||||||
void MainWindow::addObject()
|
void MainWindow::addObject()
|
||||||
{
|
{
|
||||||
this->stopProcessing();
|
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||||
AddObjectDialog dialog(camera_, &objects_, this);
|
AddObjectDialog dialog(camera_, &objects_, this);
|
||||||
if(dialog.exec() == QDialog::Accepted)
|
if(dialog.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
showObject(objects_.last());
|
showObject(objects_.last());
|
||||||
}
|
}
|
||||||
|
this->startProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showObject(ObjWidget * obj)
|
void MainWindow::showObject(ObjWidget * obj)
|
||||||
@ -500,5 +504,17 @@ void MainWindow::update(const cv::Mat & image)
|
|||||||
ui_->label_timeGui->setText(QString::number(time.restart()));
|
ui_->label_timeGui->setText(QString::number(time.restart()));
|
||||||
}
|
}
|
||||||
ui_->label_detectorDescriptorType->setText(QString("%1/%2").arg(Settings::currentDetectorType()).arg(Settings::currentDescriptorType()));
|
ui_->label_detectorDescriptorType->setText(QString("%1/%2").arg(Settings::currentDetectorType()).arg(Settings::currentDescriptorType()));
|
||||||
ui_->label_timeRefreshRate->setText(QString("(%1 Hz - %2 Hz)").arg(QString::number(Settings::getCamera_imageRate().toInt())).arg(QString::number(int(1000.0f/(float)(updateRate_.restart()) + 1))));
|
|
||||||
|
int refreshRate = qRound(1000.0f/float(updateRate_.restart()));
|
||||||
|
if(refreshRate > 0 && refreshRate < lowestRefreshRate_)
|
||||||
|
{
|
||||||
|
lowestRefreshRate_ = refreshRate;
|
||||||
|
}
|
||||||
|
// Refresh the label only after each 1000 ms
|
||||||
|
if(refreshStartTime_.elapsed() > 1000)
|
||||||
|
{
|
||||||
|
ui_->label_timeRefreshRate->setText(QString("(%1 Hz - %2 Hz)").arg(QString::number(Settings::getCamera_imageRate().toInt())).arg(QString::number(lowestRefreshRate_)));
|
||||||
|
lowestRefreshRate_ = 99;
|
||||||
|
refreshStartTime_.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,15 +28,18 @@ public:
|
|||||||
|
|
||||||
void loadObjects(const QString & fileName);
|
void loadObjects(const QString & fileName);
|
||||||
void saveObjects(const QString & fileName);
|
void saveObjects(const QString & fileName);
|
||||||
void startProcessing();
|
|
||||||
void stopProcessing();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent * event);
|
virtual void closeEvent(QCloseEvent * event);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void startProcessing();
|
||||||
|
void stopProcessing();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadObjects();
|
void loadObjects();
|
||||||
void saveObjects();
|
void saveObjects();
|
||||||
|
void addObject();
|
||||||
void removeObject(ObjWidget * object);
|
void removeObject(ObjWidget * object);
|
||||||
void update(const cv::Mat & image);
|
void update(const cv::Mat & image);
|
||||||
|
|
||||||
@ -44,7 +47,6 @@ signals:
|
|||||||
void objectsFound(const QMap<int, QPoint> &);
|
void objectsFound(const QMap<int, QPoint> &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addObject();
|
|
||||||
void showObject(ObjWidget * obj);
|
void showObject(ObjWidget * obj);
|
||||||
void updateData();
|
void updateData();
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ private:
|
|||||||
cv::Mat dataTree_;
|
cv::Mat dataTree_;
|
||||||
QList<int> dataRange_;
|
QList<int> dataRange_;
|
||||||
QTime updateRate_;
|
QTime updateRate_;
|
||||||
|
QTime refreshStartTime_;
|
||||||
|
int lowestRefreshRate_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user