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