Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/other/maptk_undistort_frames.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# Path to the input image list file.
image_list_file = framelist.txt

# A directory containing the input KRTD files.
input_krtd_dir = output/krtd

# A directory in which to write the output undistorted frames.
output_dir = undistorted_frames
2 changes: 2 additions & 0 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ set(gui_moc_headers
tools/BundleAdjustTool.h
tools/CanonicalTransformTool.h
tools/NeckerReversalTool.h
tools/UndistortFramesTool.h
)

set(gui_sources
Expand Down Expand Up @@ -90,6 +91,7 @@ set(gui_sources
tools/BundleAdjustTool.cxx
tools/CanonicalTransformTool.cxx
tools/NeckerReversalTool.cxx
tools/UndistortFramesTool.cxx
)

maptk_use_appdata(
Expand Down
34 changes: 34 additions & 0 deletions gui/MainWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "tools/BundleAdjustTool.h"
#include "tools/CanonicalTransformTool.h"
#include "tools/NeckerReversalTool.h"
#include "tools/UndistortFramesTool.h"

#include "AboutDialog.h"
#include "MatchMatrixWindow.h"
Expand Down Expand Up @@ -238,6 +239,8 @@ class MainWindowPrivate
kwiver::vital::camera_map_sptr cameraMap() const;
void updateCameras(kwiver::vital::camera_map_sptr const&);

QMap<kwiver::vital::frame_id_t, QString>* frameMap() const;

void setActiveCamera(int);
void updateCameraView();

Expand Down Expand Up @@ -391,6 +394,23 @@ kwiver::vital::camera_map_sptr MainWindowPrivate::cameraMap() const
return std::make_shared<kwiver::vital::simple_camera_map>(map);
}

//-----------------------------------------------------------------------------
QMap<kwiver::vital::frame_id_t, QString> *MainWindowPrivate::frameMap() const
{
auto map = new QMap<kwiver::vital::frame_id_t, QString>();

foreach (auto i, qtIndexRange(this->cameras.count()))
{
auto const& cd = this->cameras[i];
if (!cd.imagePath.isEmpty())
{
map->insert(static_cast<kwiver::vital::frame_id_t>(i), cd.imagePath);
}
}

return map;
}

//-----------------------------------------------------------------------------
void MainWindowPrivate::updateCameras(
kwiver::vital::camera_map_sptr const& cameras)
Expand Down Expand Up @@ -590,6 +610,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
d->addTool(new BundleAdjustTool(this), this);
d->addTool(new CanonicalTransformTool(this), this);
d->addTool(new NeckerReversalTool(this), this);
d->addTool(new UndistortFramesTool(this), this);

d->UI.menuView->addSeparator();
d->UI.menuView->addAction(d->UI.cameraViewDock->toggleViewAction());
Expand Down Expand Up @@ -1092,6 +1113,19 @@ void MainWindow::executeTool(QObject* object)
tool->setCameras(d->cameraMap());
tool->setLandmarks(d->landmarks);

if (tool->inherits("UndistortFramesTool")) {

QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"./",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);

UndistortFramesTool * t = qobject_cast<UndistortFramesTool*>(tool);

t->setOutputDir(dir);
t->setFrames(d->frameMap());
}

if (!tool->execute())
{
d->setActiveTool(0);
Expand Down
141 changes: 141 additions & 0 deletions gui/tools/UndistortFramesTool.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*ckwg +29
* Copyright 2016 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 the name 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 "UndistortFramesTool.h"

#include "maptk/undistort_frame.h"

#include <QtGui/QMessageBox>

//-----------------------------------------------------------------------------
class UndistortFramesToolPrivate
{
public:
QMap<kwiver::vital::frame_id_t, QString> frames;
QString dir;

};

QTE_IMPLEMENT_D_FUNC(UndistortFramesTool)

//-----------------------------------------------------------------------------
UndistortFramesTool::UndistortFramesTool(QObject* parent)
: AbstractTool(parent), d_ptr(new UndistortFramesToolPrivate)
{
this->setText("&Undistort Frames");
this->setToolTip(
"<nobr>Undistort frames.</nobr>");
}

//-----------------------------------------------------------------------------
UndistortFramesTool::~UndistortFramesTool()
{
}

//-----------------------------------------------------------------------------
AbstractTool::Outputs UndistortFramesTool::outputs() const
{
return Cameras | Landmarks;
}

//-----------------------------------------------------------------------------
void UndistortFramesTool::setFrames(QMap<kwiver::vital::frame_id_t, QString> *
const& newFrames)
{
if (newFrames)
{
auto copiedFrames = QMap<kwiver::vital::frame_id_t, QString>();

QMap<kwiver::vital::frame_id_t, QString>::const_iterator i =
newFrames->constBegin();

while (i != newFrames->constEnd()) {
copiedFrames.insert(i.key(), i.value());
++i;
}

this->updateFrames(copiedFrames);
}
else
{
this->updateFrames(QMap<kwiver::vital::frame_id_t, QString>());
}
}

void UndistortFramesTool::setOutputDir(const QString &dir)
{
QTE_D();

d->dir = dir;
}

//-----------------------------------------------------------------------------
void UndistortFramesTool::updateFrames(QMap<kwiver::vital::frame_id_t, QString>
const& newFrames)
{
QTE_D();
d->frames = newFrames;
}

//-----------------------------------------------------------------------------
QMap<kwiver::vital::frame_id_t, QString> UndistortFramesTool::frames()
{
QTE_D();

return d->frames;
}

//-----------------------------------------------------------------------------
bool UndistortFramesTool::execute(QWidget* window)
{
return AbstractTool::execute(window);
}

//-----------------------------------------------------------------------------
void UndistortFramesTool::run()
{
QTE_D();

auto cp = this->cameras();
auto frames = this->frames();

int nbCams = cp.get()->cameras().size();

std::vector<std::string> frameList;
std::vector<kwiver::vital::camera_sptr> cameras;

for (int i = 0; i < nbCams; ++i)
{
frameList.push_back(frames[i].toStdString());
cameras.push_back(cp.get()->cameras().at(i));
}

kwiver::maptk::undistortFrames(frameList,cameras,d->dir.toStdString());
}
68 changes: 68 additions & 0 deletions gui/tools/UndistortFramesTool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*ckwg +29
* Copyright 2016 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 the name 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.
*/

#ifndef MAPTK_UNDISTORTFRAMESTOOL_H_
#define MAPTK_UNDISTORTFRAMESTOOL_H_

#include "AbstractTool.h"

class UndistortFramesToolPrivate;

class UndistortFramesTool : public AbstractTool
{
Q_OBJECT

public:
explicit UndistortFramesTool(QObject* parent = 0);
virtual ~UndistortFramesTool();

virtual Outputs outputs() const QTE_OVERRIDE;

virtual bool execute(QWidget* window = 0) QTE_OVERRIDE;

void setFrames(QMap<kwiver::vital::frame_id_t, QString> * const &newFrames);

void setOutputDir(QString const &dir);

void updateFrames(QMap<kwiver::vital::frame_id_t, QString> const &newFrames);

QMap<kwiver::vital::frame_id_t, QString> frames();


protected:
virtual void run() QTE_OVERRIDE;

private:
QTE_DECLARE_PRIVATE_RPTR(UndistortFramesTool)
QTE_DECLARE_PRIVATE(UndistortFramesTool)
QTE_DISABLE_COPY(UndistortFramesTool)
};

#endif
8 changes: 8 additions & 0 deletions maptk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ include(CheckCXXCompilerFlag)
include_directories("${MAPTK_SOURCE_DIR}")
include_directories("${MAPTK_BINARY_DIR}")

find_package(VTK 6.2 REQUIRED)
include(${VTK_USE_FILE})


###
# Setting up main library
Expand All @@ -19,6 +22,7 @@ set(maptk_public_headers
match_matrix.h
triangulate.h
transform.h
undistort_frame.h

plugin_interface/algorithm_plugin_interface.h
plugin_interface/algorithm_plugin_interface_macros.h
Expand All @@ -38,6 +42,7 @@ set(maptk_sources
projected_track_set.cxx
transform.cxx
triangulate.cxx
undistort_frame.cxx
)

kwiver_configure_file( version.h
Expand Down Expand Up @@ -69,6 +74,9 @@ kwiver_add_library(
target_link_libraries( maptk
PUBLIC vital
kwiversys
vtkCommonCore
vtksys
vtkIOImage
)


Expand Down
Loading