-
Notifications
You must be signed in to change notification settings - Fork 150
Launch Plane Sweep Algorithm from GUI #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ALouis38
wants to merge
12
commits into
Kitware:master
Choose a base branch
from
ALouis38:Launch_PSL
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2a09d9f
Added a launching window for Plane Sweep Lib directly into the GUI
ALouis38 ce1203b
Added a file explorer and modified the output dialog
ALouis38 550efdf
Modified casts in LaunchPlaneSweepView
ALouis38 564d535
Replaced std::string by QString
ALouis38 6520ae8
Replaced parameters according to new function definition
ALouis38 c203975
Fixed doublespinbox for min depth
ALouis38 d534161
Added an initializeValues function
ALouis38 2f1e1ba
Modified the combo boxes initialisation
ALouis38 3f3beee
Dialog window is now named "Output Trace"
ALouis38 9abadd0
Only activate the Depthmaps computation menu when a project is loaded
ALouis38 f583429
Merge branch 'master' of https://github.com/Kitware/maptk into Launch…
ALouis38 5200339
Updated copyright
ALouis38 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,351 @@ | ||
| /*ckwg +29 | ||
| * Copyright 2015 by Kitware, Inc. | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * * Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * | ||
| * * Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * * Neither name of Kitware, Inc. nor the names of any contributors may be used | ||
| * to endorse or promote products derived from this software without specific | ||
| * prior written permission. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR | ||
| * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| */ | ||
|
|
||
| #include "LaunchPlaneSweepView.h" | ||
|
|
||
| #include "ui_LaunchPlaneSweepView.h" | ||
|
|
||
| #include "OutputDialog.h" | ||
|
|
||
| #include <qtUiState.h> | ||
| #include <qtUiStateItem.h> | ||
| #include <sstream> | ||
| #include <iostream> | ||
| #include <fstream> | ||
| #include <string> | ||
| #include <QProcess> | ||
| #include <QByteArray> | ||
| #include <QFileDialog> | ||
|
|
||
| /////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| //BEGIN LaunchPlaneSweepViewPrivate | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| class LaunchPlaneSweepViewPrivate | ||
| { | ||
| public: | ||
|
|
||
| Ui::LaunchPlaneSweepView UI; | ||
| qtUiState uiState; | ||
|
|
||
| QStringList args; | ||
|
|
||
| QProcess *psl; | ||
|
|
||
| QString krtdFolder; | ||
| QString framesFolder; | ||
| QString frameList; | ||
| QString landmarksFile; | ||
|
|
||
| void addArg(QWidget* item, QString value=""); | ||
| void addArg(QWidget *item, double value); | ||
|
|
||
| OutputDialog* dialog; | ||
| }; | ||
|
|
||
| QTE_IMPLEMENT_D_FUNC(LaunchPlaneSweepView) | ||
|
|
||
| //END LaunchPlaneSweepViewPrivate | ||
|
|
||
| //BEGIN LaunchPlaneSweepView | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| LaunchPlaneSweepView::LaunchPlaneSweepView(QWidget* parent, Qt::WindowFlags flags) | ||
| : QWidget(parent, flags), d_ptr(new LaunchPlaneSweepViewPrivate) | ||
| { | ||
| QTE_D(); | ||
|
|
||
| this->setAttribute(Qt::WA_DeleteOnClose); | ||
|
|
||
| // Set up UI | ||
| d->UI.setupUi(this); | ||
|
|
||
| // Set up UI persistence and restore previous state | ||
| d->uiState.setCurrentGroup("LaunchPlaneSweepView"); | ||
|
|
||
|
|
||
| // Set up signals/slots | ||
| connect(d->UI.pushButtonCompute, SIGNAL(clicked(bool)), | ||
| this, SLOT(compute())); | ||
|
|
||
| connect(d->UI.checkBoxDepthAuto, SIGNAL(toggled(bool)), | ||
| d->UI.doubleSpinBoxDepthMin, SLOT(setDisabled(bool))); | ||
|
|
||
|
|
||
| connect(d->UI.checkBoxDepthAuto, SIGNAL(toggled(bool)), | ||
| d->UI.doubleSpinBoxDepthMax, SLOT(setDisabled(bool))); | ||
|
|
||
| connect(d->UI.comboBoxMatchCost, SIGNAL(currentIndexChanged(int)), | ||
| this, SLOT(enableColorMatching())); | ||
|
|
||
| d->dialog = new OutputDialog(); | ||
|
|
||
| d->psl = new QProcess(); | ||
|
|
||
| connect(d->psl, SIGNAL(readyRead()), | ||
| d->dialog, SLOT(ouputProcess())); | ||
|
|
||
| connect(d->psl, SIGNAL(finished(int)), | ||
| this, SLOT(initialState())); | ||
|
|
||
| connect(d->UI.pushButtonStop, SIGNAL(clicked(bool)), | ||
| d->psl, SLOT(kill())); | ||
|
|
||
| connect(d->UI.pushButtonExplore, SIGNAL(clicked(bool)), | ||
| this, SLOT(openFileExplorer())); | ||
|
|
||
| initializeComboBoxes(); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| LaunchPlaneSweepView::~LaunchPlaneSweepView() | ||
| { | ||
| QTE_D(); | ||
| d->uiState.save(); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::setKrtdFolder(QString krtdFolder) | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->krtdFolder = "--krtdFolder="+krtdFolder; | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::setLandmarksFile(QString landmarksFile) | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->landmarksFile = "--landmarksPLY=" + landmarksFile; | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::compute() | ||
| { | ||
| QTE_D(); | ||
|
|
||
| QString pslPath = d->UI.lineEditPSLPath->text(); | ||
|
|
||
| d->args << "--debug"; | ||
|
|
||
| //Getting frame folder | ||
|
|
||
| std::ifstream frameList(d->frameList.toStdString()); | ||
| std::string framePath, frameFolder, imageListFile; | ||
|
|
||
| imageListFile = "--imageListFile=" + d->frameList.toStdString(); | ||
|
|
||
| frameList >> framePath; | ||
| frameFolder = framePath.substr(0,framePath.find_last_of("/\\")); | ||
|
|
||
| frameList.close(); | ||
|
|
||
| frameFolder = "--frameFolder=" + frameFolder; | ||
|
|
||
| d->args << QString::fromStdString(frameFolder) ; | ||
| d->args << d->krtdFolder; | ||
| d->args << QString::fromStdString(imageListFile); | ||
| d->args << d->landmarksFile; | ||
|
|
||
| //Parsing arguments from form | ||
|
|
||
| for (int i = 0; i < this->children().size(); ++i) | ||
| { | ||
| if (this->children().at(i)->inherits("QCheckBox")) | ||
| { | ||
| QCheckBox *child = qobject_cast<QCheckBox*>(this->children().at(i)); | ||
|
|
||
| if (child->isChecked()) | ||
| { | ||
| d->addArg(child); | ||
| } | ||
| } | ||
| else if (this->children().at(i)->inherits("QComboBox")) | ||
| { | ||
| QComboBox *child = qobject_cast<QComboBox*>(this->children().at(i)); | ||
|
|
||
| d->addArg(child, child->itemData(child->currentIndex()).toString()); | ||
| } | ||
| else if (this->children().at(i)->inherits("QSpinBox")) | ||
| { | ||
| QSpinBox *child = qobject_cast<QSpinBox*>(this->children().at(i)); | ||
|
|
||
| d->addArg(child,child->value()); | ||
| } | ||
| } | ||
|
|
||
| d->addArg(d->UI.lineEditOutputDirectory, d->UI.lineEditOutputDirectory->text()); | ||
|
|
||
|
|
||
| d->dialog->show(); | ||
| d->dialog->setOutputToDisplay(d->psl); | ||
|
|
||
| runningState(); | ||
|
|
||
| d->psl->setProcessChannelMode(QProcess::MergedChannels); | ||
| d->psl->start(pslPath,d->args); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::enableColorMatching() | ||
| { | ||
|
|
||
| QTE_D(); | ||
|
|
||
| if (d->UI.comboBoxMatchCost->currentText().toStdString() == "SAD") | ||
| { | ||
| d->UI.checkBoxColorMatching->setEnabled(true); | ||
| d->UI.checkBoxColorMatching->setChecked(true); | ||
| } | ||
| else | ||
| { | ||
| d->UI.checkBoxColorMatching->setEnabled(false); | ||
| d->UI.checkBoxColorMatching->setChecked(false); | ||
| } | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::setFrameList(QString frameList) | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->frameList = frameList; | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::setNumCam(int numCam) | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->UI.spinBoxFrameSample->setMaximum(numCam); | ||
| d->UI.spinBoxRefFrameStep->setMaximum(numCam); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::initalizeValues(QString krtdFolder, | ||
| QString landmarksFile, | ||
| QString frameList, int numCam) | ||
| { | ||
| setKrtdFolder(krtdFolder); | ||
| setLandmarksFile(landmarksFile); | ||
| setFrameList(frameList); | ||
| setNumCam(numCam); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::initialState() | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->args.clear(); | ||
| for (int i = 0; i < this->children().size(); ++i) { | ||
| if (this->children().at(i)->inherits("QWidget")) { | ||
| QWidget *child = qobject_cast<QWidget*>(this->children().at(i)); | ||
| child->setEnabled(true); | ||
| } | ||
| } | ||
| d->UI.pushButtonStop->setEnabled(false); | ||
|
|
||
| d->UI.doubleSpinBoxDepthMin->setEnabled(false); | ||
| d->UI.doubleSpinBoxDepthMax->setEnabled(false); | ||
|
|
||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::openFileExplorer() | ||
| { | ||
| QTE_D(); | ||
| QString path = QFileDialog::getOpenFileName(); | ||
|
|
||
| d->UI.lineEditPSLPath->setText(path); | ||
|
|
||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::runningState() | ||
| { | ||
| QTE_D(); | ||
|
|
||
| for (int i = 0; i < this->children().size(); ++i) | ||
| { | ||
| if (this->children().at(i)->inherits("QWidget")) | ||
| { | ||
| QWidget *child = qobject_cast<QWidget*>(this->children().at(i)); | ||
| child->setEnabled(false); | ||
| } | ||
| } | ||
| d->UI.pushButtonStop->setEnabled(true); | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepView::initializeComboBoxes() | ||
| { | ||
| QTE_D(); | ||
|
|
||
| d->UI.comboBoxMatchCost->addItem("SAD",QVariant("SAD")); | ||
| d->UI.comboBoxMatchCost->addItem("ZNCC",QVariant("ZNCC")); | ||
|
|
||
| d->UI.comboBoxOcclusionMode->addItem("None",QVariant("None")); | ||
| d->UI.comboBoxOcclusionMode->addItem("Ref Split",QVariant("RefSplit")); | ||
| d->UI.comboBoxOcclusionMode->addItem("Best K",QVariant("BestK")); | ||
|
|
||
| d->UI.comboBoxOutputs->addItem("VTI files only",QVariant("vti")); | ||
| d->UI.comboBoxOutputs->addItem("VTI and VTS",QVariant("vts")); | ||
| d->UI.comboBoxOutputs->addItem("VTI and VTP",QVariant("vtp")); | ||
| d->UI.comboBoxOutputs->addItem("VTI, VTP and VTS files",QVariant("vtpvts")); | ||
| d->UI.comboBoxOutputs->addItem("VTI and VRML files",QVariant("vrml")); | ||
| } | ||
|
|
||
| //END LaunchPlaneSweepView | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepViewPrivate::addArg(QWidget *item, QString value) | ||
| { | ||
| QString arg = item->property("configField").toString(); | ||
|
|
||
| if(!value.isEmpty()) | ||
| { | ||
| arg = arg + "=" + value; | ||
| } | ||
| args << arg; | ||
|
|
||
| } | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| void LaunchPlaneSweepViewPrivate::addArg(QWidget *item, double value) | ||
| { | ||
| std::ostringstream sstream; | ||
| sstream << value; | ||
| std::string valueStr = sstream.str(); | ||
|
|
||
| addArg(item,QString::fromStdString(valueStr)); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright 2016