Many minor changes
git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@79 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
aa1d2f67e9
commit
3fe16927fc
@ -19,10 +19,10 @@
|
||||
#include <opencv2/imgproc/imgproc_c.h>
|
||||
#include <opencv2/highgui/highgui_c.h>
|
||||
|
||||
AddObjectDialog::AddObjectDialog(Camera * camera, QList<ObjWidget*> * objects, bool mirrorView, QWidget * parent, Qt::WindowFlags f) :
|
||||
AddObjectDialog::AddObjectDialog(Camera * camera, const IplImage * image, bool mirrorView, QWidget * parent, Qt::WindowFlags f) :
|
||||
QDialog(parent, f),
|
||||
camera_(camera),
|
||||
objects_(objects),
|
||||
object_(0),
|
||||
cvImage_(0)
|
||||
{
|
||||
ui_ = new Ui_addObjectDialog();
|
||||
@ -38,7 +38,16 @@ AddObjectDialog::AddObjectDialog(Camera * camera, QList<ObjWidget*> * objects, b
|
||||
connect(ui_->cameraView, SIGNAL(roiChanged(const QRect &)), this, SLOT(updateNextButton(const QRect &)));
|
||||
ui_->cameraView->setMirrorView(mirrorView);
|
||||
|
||||
this->setState(kTakePicture);
|
||||
if((camera_ && camera_->isRunning()) || !image)
|
||||
{
|
||||
this->setState(kTakePicture);
|
||||
}
|
||||
else if(image)
|
||||
{
|
||||
cv::Mat img(image);
|
||||
update(img);
|
||||
this->setState(kSelectFeatures);
|
||||
}
|
||||
}
|
||||
|
||||
AddObjectDialog::~AddObjectDialog()
|
||||
@ -47,12 +56,19 @@ AddObjectDialog::~AddObjectDialog()
|
||||
{
|
||||
cvReleaseImage(&cvImage_);
|
||||
}
|
||||
if(object_)
|
||||
{
|
||||
delete object_;
|
||||
}
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void AddObjectDialog::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
if(camera_)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
}
|
||||
QDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
@ -141,11 +157,14 @@ void AddObjectDialog::setState(int state)
|
||||
}
|
||||
else if(state == kSelectFeatures)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
camera_->pause();
|
||||
if(camera_)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
camera_->pause();
|
||||
}
|
||||
|
||||
ui_->pushButton_cancel->setEnabled(true);
|
||||
ui_->pushButton_back->setEnabled(true);
|
||||
ui_->pushButton_back->setEnabled(camera_);
|
||||
ui_->pushButton_next->setEnabled(false);
|
||||
ui_->pushButton_takePicture->setEnabled(false);
|
||||
ui_->pushButton_next->setText(tr("Next"));
|
||||
@ -168,8 +187,11 @@ void AddObjectDialog::setState(int state)
|
||||
}
|
||||
else if(state == kVerifySelection)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
camera_->pause();
|
||||
if(camera_)
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
camera_->pause();
|
||||
}
|
||||
|
||||
ui_->pushButton_cancel->setEnabled(true);
|
||||
ui_->pushButton_back->setEnabled(true);
|
||||
@ -262,7 +284,12 @@ void AddObjectDialog::setState(int state)
|
||||
}
|
||||
}
|
||||
|
||||
objects_->append(new ObjWidget(0, keypoints, descriptors, ui_->objectView->iplImage(), Settings::currentDetectorType(), Settings::currentDescriptorType()));
|
||||
if(object_)
|
||||
{
|
||||
delete object_;
|
||||
object_ = 0;
|
||||
}
|
||||
object_ = new ObjWidget(0, keypoints, descriptors, ui_->objectView->iplImage(), Settings::currentDetectorType(), Settings::currentDescriptorType());
|
||||
|
||||
this->accept();
|
||||
}
|
||||
|
||||
@ -20,9 +20,12 @@ class AddObjectDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AddObjectDialog(Camera * camera, QList<ObjWidget*> * objects, bool mirrorView, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||
AddObjectDialog(Camera * camera, const IplImage * image, bool mirrorView, QWidget * parent = 0, Qt::WindowFlags f = 0);
|
||||
virtual ~AddObjectDialog();
|
||||
|
||||
// ownership transferred to caller
|
||||
ObjWidget * retrieveObject() {ObjWidget * obj = object_; object_=0; return obj;}
|
||||
|
||||
private slots:
|
||||
void update(const cv::Mat &);
|
||||
void next();
|
||||
@ -42,7 +45,7 @@ private:
|
||||
private:
|
||||
Ui_addObjectDialog * ui_;
|
||||
Camera * camera_;
|
||||
QList<ObjWidget*> * objects_;
|
||||
ObjWidget * object_;
|
||||
IplImage * cvImage_;
|
||||
|
||||
enum State{kTakePicture, kSelectFeatures, kVerifySelection, kClosing};
|
||||
|
||||
@ -66,6 +66,7 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
||||
connect(ui_->toolBox, SIGNAL(parametersChanged()), this, SLOT(notifyParametersChanged()));
|
||||
|
||||
ui_->imageView_source->setGraphicsViewMode(false);
|
||||
ui_->imageView_source->setTextLabel(tr("Press \"space\" to start camera..."));
|
||||
|
||||
//reset button
|
||||
connect(ui_->pushButton_restoreDefaults, SIGNAL(clicked()), ui_->toolBox, SLOT(resetCurrentPage()));
|
||||
@ -77,7 +78,7 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
||||
ui_->actionSave_objects->setEnabled(false);
|
||||
|
||||
// Actions
|
||||
connect(ui_->actionAdd_object, SIGNAL(triggered()), this, SLOT(addObject()));
|
||||
connect(ui_->actionAdd_object_from_scene, SIGNAL(triggered()), this, SLOT(addObjectFromScene()));
|
||||
connect(ui_->actionAdd_objects_from_files, SIGNAL(triggered()), this, SLOT(addObjectsFromFiles()));
|
||||
connect(ui_->actionLoad_scene_from_file, SIGNAL(triggered()), this, SLOT(loadSceneFromFile()));
|
||||
connect(ui_->actionStart_camera, SIGNAL(triggered()), this, SLOT(startProcessing()));
|
||||
@ -86,16 +87,16 @@ MainWindow::MainWindow(Camera * camera, QWidget * parent) :
|
||||
connect(ui_->actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
connect(ui_->actionSave_objects, SIGNAL(triggered()), this, SLOT(saveObjects()));
|
||||
connect(ui_->actionLoad_objects, SIGNAL(triggered()), this, SLOT(loadObjects()));
|
||||
connect(ui_->actionSetup_camera_from_video_file, SIGNAL(triggered()), this, SLOT(setupCameraFromVideoFile()));
|
||||
connect(ui_->actionSetup_camera_from_video_file_2, SIGNAL(triggered()), this, SLOT(setupCameraFromVideoFile()));
|
||||
connect(ui_->actionCamera_from_video_file, SIGNAL(triggered()), this, SLOT(setupCameraFromVideoFile()));
|
||||
connect(ui_->actionAbout, SIGNAL(triggered()), aboutDialog_ , SLOT(exec()));
|
||||
connect(ui_->actionRestore_all_default_settings, SIGNAL(triggered()), ui_->toolBox, SLOT(resetAllPages()));
|
||||
connect(ui_->actionRemove_all_objects, SIGNAL(triggered()), this, SLOT(removeAllObjects()));
|
||||
|
||||
ui_->actionSetup_camera_from_video_file->setCheckable(true);
|
||||
ui_->actionSetup_camera_from_video_file_2->setCheckable(true);
|
||||
ui_->actionSetup_camera_from_video_file->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
ui_->actionSetup_camera_from_video_file_2->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
ui_->actionStart_camera->setShortcut(Qt::Key_Space);
|
||||
ui_->actionPause_camera->setShortcut(Qt::Key_Space);
|
||||
|
||||
ui_->actionCamera_from_video_file->setCheckable(true);
|
||||
ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
|
||||
if(Settings::getGeneral_autoStartCamera())
|
||||
{
|
||||
@ -155,8 +156,7 @@ void MainWindow::loadObjects(const QString & dirPath)
|
||||
QDir dir(dirPath);
|
||||
if(dir.exists())
|
||||
{
|
||||
QStringList filters;
|
||||
filters << "*.png" << "*.jpg" << "*.bmp" << "*.tiff";
|
||||
QStringList filters = Settings::getGeneral_imageFormats().split(' ');
|
||||
QFileInfoList list = dir.entryInfoList(filters, QDir::Files, QDir::Name);
|
||||
for(int i=0; i<list.size(); ++i)
|
||||
{
|
||||
@ -207,34 +207,69 @@ void MainWindow::removeObject(ObjWidget * object)
|
||||
objects_.removeOne(object);
|
||||
object->deleteLater();
|
||||
this->updateData();
|
||||
if(!camera_->isRunning() && ui_->imageView_source->iplImage())
|
||||
{
|
||||
cv::Mat image(ui_->imageView_source->iplImage(), true);
|
||||
this->update(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::removeAllObjects()
|
||||
{
|
||||
QList<ObjWidget*> obj = objects_;
|
||||
for(int i=0; i<obj.size(); ++i)
|
||||
for(int i=0; i<objects_.size(); ++i)
|
||||
{
|
||||
removeObject(obj[i]);
|
||||
delete objects_.at(i);
|
||||
}
|
||||
objects_.clear();
|
||||
this->updateData();
|
||||
if(!camera_->isRunning() && ui_->imageView_source->iplImage())
|
||||
{
|
||||
cv::Mat image(ui_->imageView_source->iplImage(), true);
|
||||
this->update(image);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::addObject()
|
||||
void MainWindow::addObjectFromScene()
|
||||
{
|
||||
disconnect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
AddObjectDialog dialog(camera_, &objects_, ui_->imageView_source->isMirrorView(), this);
|
||||
if(dialog.exec() == QDialog::Accepted)
|
||||
AddObjectDialog * dialog;
|
||||
bool resumeCamera = camera_->isRunning();
|
||||
if(!ui_->actionStart_camera->isEnabled() || !ui_->imageView_source->iplImage())
|
||||
{
|
||||
showObject(objects_.last());
|
||||
updateData();
|
||||
objectsModified_ = true;
|
||||
dialog = new AddObjectDialog(camera_, ui_->imageView_source->iplImage(), ui_->imageView_source->isMirrorView(), this);
|
||||
}
|
||||
this->startProcessing();
|
||||
else
|
||||
{
|
||||
dialog = new AddObjectDialog(0, ui_->imageView_source->iplImage(), ui_->imageView_source->isMirrorView(), this);
|
||||
}
|
||||
if(dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
ObjWidget * obj = dialog->retrieveObject();
|
||||
if(obj)
|
||||
{
|
||||
objects_.push_back(obj);
|
||||
showObject(objects_.last());
|
||||
updateData();
|
||||
objectsModified_ = true;
|
||||
}
|
||||
}
|
||||
if(resumeCamera || !ui_->imageView_source->iplImage())
|
||||
{
|
||||
this->startProcessing();
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
cv::Mat image(ui_->imageView_source->iplImage(), true);
|
||||
this->update(image);
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void MainWindow::addObjectsFromFiles()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Add objects..."), Settings::workingDirectory(), tr("Image Files (*.png *.jpg *.bmp *.tiff)"));
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Add objects..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats()));
|
||||
if(fileNames.size())
|
||||
{
|
||||
for(int i=0; i<fileNames.size(); ++i)
|
||||
@ -248,6 +283,7 @@ void MainWindow::addObjectsFromFiles()
|
||||
|
||||
void MainWindow::addObjectFromFile(const QString & filePath)
|
||||
{
|
||||
printf("Load file %s\n", filePath.toStdString().c_str());
|
||||
if(!filePath.isNull())
|
||||
{
|
||||
IplImage * img = cvLoadImage(filePath.toStdString().c_str(), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
@ -258,12 +294,10 @@ void MainWindow::addObjectFromFile(const QString & filePath)
|
||||
QStringList list = file.fileName().split('.');
|
||||
if(list.size())
|
||||
{
|
||||
printf("asdfddsa %s\n", list.front().toStdString().c_str());
|
||||
bool ok = false;
|
||||
id = list.front().toInt(&ok);
|
||||
if(ok)
|
||||
{
|
||||
printf("id=%d\n", id);
|
||||
for(int i=0; i<objects_.size(); ++i)
|
||||
{
|
||||
if(objects_.at(i)->id() == id)
|
||||
@ -295,7 +329,7 @@ void MainWindow::addObjectFromFile(const QString & filePath)
|
||||
|
||||
void MainWindow::loadSceneFromFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load scene..."), Settings::workingDirectory(), tr("Image Files (*.png *.jpg *.bmp *.tiff)"));
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load scene..."), Settings::workingDirectory(), tr("Image Files (%1)").arg(Settings::getGeneral_imageFormats()));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
IplImage * img = cvLoadImage(fileName.toStdString().c_str());
|
||||
@ -311,17 +345,26 @@ void MainWindow::loadSceneFromFile()
|
||||
|
||||
void MainWindow::setupCameraFromVideoFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Setup camera from video file..."), Settings::workingDirectory(), tr("Video Files (*.avi *.m4v)"));
|
||||
if(!fileName.isEmpty())
|
||||
if(!ui_->actionCamera_from_video_file->isChecked())
|
||||
{
|
||||
Settings::setCamera_videoFilePath(fileName);
|
||||
Settings::setCamera_videoFilePath("");
|
||||
ui_->toolBox->updateParameter(Settings::kCamera_videoFilePath());
|
||||
if(camera_->isRunning())
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Setup camera from video file..."), Settings::workingDirectory(), tr("Video Files (%1)").arg(Settings::getGeneral_videoFormats()));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
this->stopProcessing();
|
||||
this->startProcessing();
|
||||
Settings::setCamera_videoFilePath(fileName);
|
||||
ui_->toolBox->updateParameter(Settings::kCamera_videoFilePath());
|
||||
if(camera_->isRunning())
|
||||
{
|
||||
this->stopProcessing();
|
||||
this->startProcessing();
|
||||
}
|
||||
}
|
||||
}
|
||||
ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
}
|
||||
|
||||
void MainWindow::showObject(ObjWidget * obj)
|
||||
@ -405,8 +448,11 @@ void MainWindow::updateObjects()
|
||||
detectorDescriptorType->setText(QString("%1/%2").arg(objects_.at(i)->detectorType()).arg(objects_.at(i)->descriptorType()));
|
||||
}
|
||||
updateData();
|
||||
notifyParametersChanged(); // this will update the scene if camera is stopped
|
||||
|
||||
}
|
||||
if(!camera_->isRunning() && ui_->imageView_source->iplImage())
|
||||
{
|
||||
cv::Mat image(ui_->imageView_source->iplImage(), true);
|
||||
this->update(image);
|
||||
}
|
||||
this->statusBar()->clearMessage();
|
||||
}
|
||||
@ -478,7 +524,11 @@ void MainWindow::updateData()
|
||||
|
||||
void MainWindow::startProcessing()
|
||||
{
|
||||
this->statusBar()->showMessage(tr("Starting camera..."));
|
||||
bool updateStatusMessage = this->statusBar()->currentMessage().isEmpty();
|
||||
if(updateStatusMessage)
|
||||
{
|
||||
this->statusBar()->showMessage(tr("Starting camera..."));
|
||||
}
|
||||
if(camera_->start())
|
||||
{
|
||||
connect(camera_, SIGNAL(imageReceived(const cv::Mat &)), this, SLOT(update(const cv::Mat &)));
|
||||
@ -487,11 +537,17 @@ void MainWindow::startProcessing()
|
||||
ui_->actionStart_camera->setEnabled(false);
|
||||
ui_->actionLoad_scene_from_file->setEnabled(false);
|
||||
ui_->label_timeRefreshRate->setVisible(true);
|
||||
this->statusBar()->showMessage(tr("Camera started."), 2000);
|
||||
if(updateStatusMessage)
|
||||
{
|
||||
this->statusBar()->showMessage(tr("Camera started."), 2000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->statusBar()->clearMessage();
|
||||
if(updateStatusMessage)
|
||||
{
|
||||
this->statusBar()->clearMessage();
|
||||
}
|
||||
if(this->isVisible())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Camera error"), tr("Camera initialization failed! (with device %1)").arg(Settings::getCamera_deviceId()));
|
||||
@ -628,7 +684,8 @@ void MainWindow::update(const cv::Mat & image)
|
||||
float maxMatchedDistance = -1.0f;
|
||||
for(int i=0; i<dataTree_.rows; ++i)
|
||||
{
|
||||
QColor color((Qt::GlobalColor)(j % 12 + 7 ));
|
||||
int nColor = j % 11 + 7;
|
||||
QColor color((Qt::GlobalColor)(nColor==Qt::yellow?Qt::gray:nColor));
|
||||
bool matched = false;
|
||||
// Check if this descriptor matches with those of the objects
|
||||
if(Settings::getNearestNeighbor_nndrRatioUsed() &&
|
||||
@ -821,6 +878,7 @@ void MainWindow::update(const cv::Mat & image)
|
||||
|
||||
void MainWindow::notifyParametersChanged()
|
||||
{
|
||||
printf("Parameters changed...\n");
|
||||
if(objects_.size())
|
||||
{
|
||||
this->statusBar()->showMessage(tr("A parameter has changed... \"Update objects\" may be required."));
|
||||
@ -832,6 +890,5 @@ void MainWindow::notifyParametersChanged()
|
||||
ui_->label_timeRefreshRate->setVisible(false);
|
||||
}
|
||||
|
||||
ui_->actionSetup_camera_from_video_file->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
ui_->actionSetup_camera_from_video_file_2->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
ui_->actionCamera_from_video_file->setChecked(!Settings::getCamera_videoFilePath().isEmpty());
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public slots:
|
||||
private slots:
|
||||
void loadObjects();
|
||||
bool saveObjects();
|
||||
void addObject();
|
||||
void addObjectFromScene();
|
||||
void addObjectsFromFiles();
|
||||
void loadSceneFromFile();
|
||||
void setupCameraFromVideoFile();
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include <QtGui/QGraphicsRectItem>
|
||||
#include <QtGui/QInputDialog>
|
||||
#include <QtGui/QPen>
|
||||
#include <QtGui/QLabel>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
|
||||
@ -72,8 +73,12 @@ void ObjWidget::setupUi()
|
||||
graphicsView_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
graphicsView_->setScene(new QGraphicsScene(graphicsView_));
|
||||
|
||||
label_ = new QLabel();
|
||||
label_->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->setLayout(new QVBoxLayout(this));
|
||||
this->layout()->addWidget(graphicsView_);
|
||||
this->layout()->addWidget(label_);
|
||||
this->layout()->setContentsMargins(0,0,0,0);
|
||||
|
||||
_menu = new QMenu(tr(""), this);
|
||||
@ -232,6 +237,11 @@ void ObjWidget::setAlpha(int alpha)
|
||||
}
|
||||
}
|
||||
|
||||
void ObjWidget::setTextLabel(const QString & text)
|
||||
{
|
||||
label_->setText(text);
|
||||
}
|
||||
|
||||
void ObjWidget::setData(const std::vector<cv::KeyPoint> & keypoints,
|
||||
const cv::Mat & descriptors,
|
||||
const IplImage * image,
|
||||
@ -247,6 +257,7 @@ void ObjWidget::setData(const std::vector<cv::KeyPoint> & keypoints,
|
||||
graphicsViewInitialized_ = false;
|
||||
detectorType_ = detectorType;
|
||||
descriptorType_ = descriptorType;
|
||||
mouseCurrentPos_ = mousePressedPos_; // this will reset roi selection
|
||||
if(iplImage_)
|
||||
{
|
||||
cvReleaseImage(&iplImage_);
|
||||
@ -270,6 +281,7 @@ void ObjWidget::setData(const std::vector<cv::KeyPoint> & keypoints,
|
||||
{
|
||||
this->setupGraphicsView();
|
||||
}
|
||||
label_->setVisible(!image);
|
||||
}
|
||||
|
||||
void ObjWidget::resetKptsColor()
|
||||
|
||||
@ -16,6 +16,7 @@ class QGraphicsView;
|
||||
class QGraphicsScene;
|
||||
class QGraphicsRectItem;
|
||||
class QGraphicsItem;
|
||||
class QLabel;
|
||||
|
||||
class ObjWidget : public QWidget
|
||||
{
|
||||
@ -38,6 +39,7 @@ public:
|
||||
const IplImage * image,
|
||||
const QString & detectorType,
|
||||
const QString & descriptorType);
|
||||
void setTextLabel(const QString & text);
|
||||
void resetKptsColor();
|
||||
void setKptColor(int index, const QColor & color);
|
||||
void setGraphicsViewMode(bool on);
|
||||
@ -104,6 +106,7 @@ private:
|
||||
QList<QGraphicsRectItem*> rectItems_;
|
||||
bool graphicsViewInitialized_;
|
||||
int alpha_;
|
||||
QLabel * label_;
|
||||
|
||||
// menu stuff
|
||||
QString _savedFileName;
|
||||
|
||||
@ -27,71 +27,61 @@ QWidget * ParametersToolBox::getParameterWidget(const QString & key)
|
||||
return this->findChild<QWidget*>(key);
|
||||
}
|
||||
|
||||
void ParametersToolBox::resetCurrentPage()
|
||||
void ParametersToolBox::resetPage(int index)
|
||||
{
|
||||
const QObjectList & children = this->widget(this->currentIndex())->children();
|
||||
const QObjectList & children = this->widget(index)->children();
|
||||
for(int j=0; j<children.size();++j)
|
||||
{
|
||||
QString key = children.at(j)->objectName();
|
||||
QVariant value = Settings::getDefaultParameters().value(key, QVariant());
|
||||
if(value.isValid())
|
||||
// ignore only the nextObjID setting, to avoid problem with saved objects
|
||||
if(key.compare(Settings::kGeneral_nextObjID()) != 0)
|
||||
{
|
||||
if(qobject_cast<QComboBox*>(children.at(j)))
|
||||
QVariant value = Settings::getDefaultParameters().value(key, QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
((QComboBox*)children.at(j))->setCurrentIndex(value.toString().split(':').first().toInt());
|
||||
if(qobject_cast<QComboBox*>(children.at(j)))
|
||||
{
|
||||
((QComboBox*)children.at(j))->setCurrentIndex(value.toString().split(':').first().toInt());
|
||||
}
|
||||
else if(qobject_cast<QSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QSpinBox*)children.at(j))->setValue(value.toInt());
|
||||
}
|
||||
else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QDoubleSpinBox*)children.at(j))->setValue(value.toDouble());
|
||||
}
|
||||
else if(qobject_cast<QCheckBox*>(children.at(j)))
|
||||
{
|
||||
((QCheckBox*)children.at(j))->setChecked(value.toBool());
|
||||
}
|
||||
else if(qobject_cast<QLineEdit*>(children.at(j)))
|
||||
{
|
||||
((QLineEdit*)children.at(j))->setText(value.toString());
|
||||
}
|
||||
Settings::setParameter(key, value);
|
||||
}
|
||||
else if(qobject_cast<QSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QSpinBox*)children.at(j))->setValue(value.toInt());
|
||||
}
|
||||
else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QDoubleSpinBox*)children.at(j))->setValue(value.toDouble());
|
||||
}
|
||||
else if(qobject_cast<QCheckBox*>(children.at(j)))
|
||||
{
|
||||
((QCheckBox*)children.at(j))->setChecked(value.toBool());
|
||||
}
|
||||
Settings::setParameter(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ParametersToolBox::resetCurrentPage()
|
||||
{
|
||||
this->blockSignals(true);
|
||||
this->resetPage(this->currentIndex());
|
||||
this->blockSignals(false);
|
||||
emit parametersChanged();
|
||||
}
|
||||
|
||||
void ParametersToolBox::resetAllPages()
|
||||
{
|
||||
this->blockSignals(true);
|
||||
for(int i=0; i< this->count(); ++i)
|
||||
{
|
||||
const QObjectList & children = this->widget(i)->children();
|
||||
for(int j=0; j<children.size();++j)
|
||||
{
|
||||
QString key = children.at(j)->objectName();
|
||||
// ignore only the nextObjID setting, to avoid problem with saved objects
|
||||
if(key.compare(Settings::kGeneral_nextObjID()) != 0)
|
||||
{
|
||||
QVariant value = Settings::getDefaultParameters().value(key, QVariant());
|
||||
if(value.isValid())
|
||||
{
|
||||
if(qobject_cast<QComboBox*>(children.at(j)))
|
||||
{
|
||||
((QComboBox*)children.at(j))->setCurrentIndex(value.toString().split(':').first().toInt());
|
||||
}
|
||||
else if(qobject_cast<QSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QSpinBox*)children.at(j))->setValue(value.toInt());
|
||||
}
|
||||
else if(qobject_cast<QDoubleSpinBox*>(children.at(j)))
|
||||
{
|
||||
((QDoubleSpinBox*)children.at(j))->setValue(value.toDouble());
|
||||
}
|
||||
else if(qobject_cast<QCheckBox*>(children.at(j)))
|
||||
{
|
||||
((QCheckBox*)children.at(j))->setChecked(value.toBool());
|
||||
}
|
||||
Settings::setParameter(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->resetPage(i);
|
||||
}
|
||||
this->blockSignals(false);
|
||||
emit parametersChanged();
|
||||
}
|
||||
|
||||
void ParametersToolBox::setupUi()
|
||||
@ -202,7 +192,7 @@ void ParametersToolBox::addParameter(QVBoxLayout * layout,
|
||||
{
|
||||
QLineEdit * widget = new QLineEdit(value, this);
|
||||
widget->setObjectName(key);
|
||||
connect(widget, SIGNAL(textChanged(const QString &)), this, SLOT(changeParameter(const QString &)));
|
||||
connect(widget, SIGNAL(editingFinished()), this, SLOT(changeParameter()));
|
||||
addParameter(layout, key.split('/').last(), widget);
|
||||
}
|
||||
}
|
||||
@ -292,6 +282,7 @@ void ParametersToolBox::changeParameter()
|
||||
{
|
||||
QDoubleSpinBox * doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
QSpinBox * spinBox = qobject_cast<QSpinBox*>(sender());
|
||||
QLineEdit * lineEdit = qobject_cast<QLineEdit*>(sender());
|
||||
if(doubleSpinBox)
|
||||
{
|
||||
Settings::setParameter(sender()->objectName(), doubleSpinBox->value());
|
||||
@ -300,6 +291,10 @@ void ParametersToolBox::changeParameter()
|
||||
{
|
||||
Settings::setParameter(sender()->objectName(), spinBox->value());
|
||||
}
|
||||
else if(lineEdit)
|
||||
{
|
||||
Settings::setParameter(sender()->objectName(), lineEdit->text());
|
||||
}
|
||||
emit parametersChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,9 @@ private slots:
|
||||
void changeParameter(const int & value);
|
||||
void resetCurrentPage();
|
||||
void resetAllPages();
|
||||
|
||||
private:
|
||||
void resetPage(int index);
|
||||
};
|
||||
|
||||
#endif /* PARAMETERSTOOLBOX_H_ */
|
||||
|
||||
@ -53,8 +53,8 @@ typedef unsigned int uint;
|
||||
class Settings
|
||||
{
|
||||
PARAMETER(Camera, deviceId, int, 0);
|
||||
PARAMETER(Camera, imageWidth, int, 640);
|
||||
PARAMETER(Camera, imageHeight, int, 480);
|
||||
PARAMETER(Camera, imageWidth, int, 0);
|
||||
PARAMETER(Camera, imageHeight, int, 0);
|
||||
PARAMETER(Camera, imageRate, int, 2); // Hz
|
||||
PARAMETER(Camera, videoFilePath, QString, "");
|
||||
|
||||
@ -127,6 +127,8 @@ class Settings
|
||||
|
||||
PARAMETER(General, autoStartCamera, bool, false);
|
||||
PARAMETER(General, nextObjID, uint, 1);
|
||||
PARAMETER(General, imageFormats, QString, "*.png *.jpg *.bmp *.tiff")
|
||||
PARAMETER(General, videoFormats, QString, "*.avi *.m4v")
|
||||
|
||||
PARAMETER(Homography, homographyComputed, bool, true);
|
||||
PARAMETER(Homography, ransacReprojThr, double, 1.0);
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>871</width>
|
||||
<height>533</height>
|
||||
<width>1104</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -130,7 +130,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>871</width>
|
||||
<width>1104</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -147,7 +147,7 @@
|
||||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<addaction name="actionAdd_object"/>
|
||||
<addaction name="actionAdd_object_from_scene"/>
|
||||
<addaction name="actionAdd_objects_from_files"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoad_scene_from_file"/>
|
||||
@ -156,8 +156,7 @@
|
||||
<addaction name="actionPause_camera"/>
|
||||
<addaction name="actionStop_camera"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSetup_camera_from_video_file"/>
|
||||
<addaction name="actionSetup_camera_from_video_file_2"/>
|
||||
<addaction name="actionCamera_from_video_file"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRestore_all_default_settings"/>
|
||||
<addaction name="separator"/>
|
||||
@ -208,7 +207,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>276</width>
|
||||
<height>393</height>
|
||||
<height>357</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@ -417,7 +416,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>274</width>
|
||||
<height>425</height>
|
||||
<height>389</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_objects">
|
||||
@ -456,9 +455,9 @@
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAdd_object">
|
||||
<action name="actionAdd_object_from_scene">
|
||||
<property name="text">
|
||||
<string>Add object...</string>
|
||||
<string>Add object from scene...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStart_camera">
|
||||
@ -506,14 +505,9 @@
|
||||
<string>Pause camera</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetup_camera_from_video_file">
|
||||
<action name="actionCamera_from_video_file">
|
||||
<property name="text">
|
||||
<string>Setup camera from video file...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetup_camera_from_video_file_2">
|
||||
<property name="text">
|
||||
<string>Setup camera from video file...</string>
|
||||
<string>Camera from video file...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove_all_objects">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user