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
3 changes: 3 additions & 0 deletions Applications/VpView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ include_directories(

set(vgSdkTargets
vgCommon
vgVideo
vgVtkVideo
qtExtensions
qtVgCommon
qtVgWidgets
vtkVgCore
vtkVgModelView
vtkVgQtUtil
vtkVgVideo
vgDataFramework
)

Expand Down Expand Up @@ -244,6 +246,7 @@ endif()
if(VISGUI_ENABLE_KWIVER)
list(APPEND vpViewSources
vpKwiverEmbeddedPipelineWorker.cxx
vpKwiverImageLoader.cxx
vpKwiverImproveTrackWorker.cxx
vpKwiverVideoSource.cxx
)
Expand Down
134 changes: 118 additions & 16 deletions Applications/VpView/vpFileDataSource.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "vpFileDataSource.h"

#include <vgKwaUtil.h>

#include <qtNaturalSort.h>

#include <QDebug>
Expand All @@ -14,12 +16,27 @@
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QStringList>
#include <QTextStream>

#include <algorithm>

namespace // anonymous
{

//-----------------------------------------------------------------------------
QByteArray readLine(QFile& f)
{
auto result = f.readLine();

const auto l = result.length();
if (l > 0 && result[l-1] == '\n')
{
result = result.left(l - 1);
}

return result;
}

//-----------------------------------------------------------------------------
QStringList glob(const QDir& base, const QString& pattern)
{
Expand All @@ -43,6 +60,9 @@ QStringList glob(const QDir& base, const QString& pattern)
class vpFileDataSourcePrivate
{
public:
void readImageList(QFile& file, const QDir& baseDir);
void readKwaIndex(QFile& file);

QString DataSetSpecifier;
QStringList DataFiles;

Expand All @@ -52,6 +72,98 @@ class vpFileDataSourcePrivate

QTE_IMPLEMENT_D_FUNC(vpFileDataSource)

//-----------------------------------------------------------------------------
void vpFileDataSourcePrivate::readImageList(QFile& file, const QDir& baseDir)
{
while (!file.atEnd())
{
const auto line = readLine(file);
if (line.isEmpty())
{
continue;
}

const auto path = baseDir.absoluteFilePath(QString::fromUtf8(line));
if (!QFileInfo{path}.exists())
{
qWarning() << "Image data file" << path << "does not exist";
continue;
}

qDebug() << "Archiving" << path;
this->DataFiles.append(path);
}
}

//-----------------------------------------------------------------------------
void vpFileDataSourcePrivate::readKwaIndex(QFile& file)
{
const auto& versionLine = readLine(file);

// Read index version
bool okay = true;
const auto version = versionLine.toInt(&okay);
if (!okay)
{
qWarning().nospace()
<< "Unable to read data source " << this->DataSetSpecifier
<< ": " << versionLine << " is not a valid KWA version number";
return;
}
if (version < 1 || version > 4)
{
qWarning().nospace()
<< "Unable to read data source " << this->DataSetSpecifier
<< ": KWA version " << version << " is not a supported";
return;
}

// Read header
auto dataName = QString::fromUtf8(readLine(file));
if (!vgKwaUtil::resolvePath(dataName, this->DataSetSpecifier, "data"))
{
return;
}
if (version > 1)
{
if (version > 2)
{
// Read name of .meta file
file.readLine();
}

// Read mission ID
file.readLine();

if (version > 3)
{
// Read stream ID
file.readLine();
}
}

// Read frames
while (!file.atEnd())
{
// Read index line
qint64 time;
quint64 offset;

auto line = QString::fromLatin1(readLine(file));
QTextStream lineStream{&line};
lineStream >> time >> offset;

if (lineStream.status() != QTextStream::Ok)
{
qWarning() << "Failed to parse KWA index entry" << line;
continue;
}

qDebug() << "Archiving" << dataName << offset;
this->DataFiles.append(dataName + "@" + QString::number(offset));
}
}

//-----------------------------------------------------------------------------
vpFileDataSource::vpFileDataSource() : d_ptr{new vpFileDataSourcePrivate}
{
Expand Down Expand Up @@ -152,23 +264,13 @@ void vpFileDataSource::update()
QFile file{d->DataSetSpecifier};
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
while (!file.atEnd())
if (d->DataSetSpecifier.toLower().endsWith(".index"))
{
d->readKwaIndex(file);
}
else
{
const auto line = file.readLine();
if (line.isEmpty())
{
continue;
}

const auto path = baseDir.absoluteFilePath(QString::fromUtf8(line));
if (!QFileInfo{path}.exists())
{
qWarning() << "Image data file" << path << "does not exist";
continue;
}

qDebug() << "Archiving" << path;
d->DataFiles.append(path);
d->readImageList(file, baseDir);
}
}
else
Expand Down
5 changes: 2 additions & 3 deletions Applications/VpView/vpKwiverEmbeddedPipelineWorker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "vpKwiverEmbeddedPipelineWorker.h"

#include "vpFileDataSource.h"
#include "vpKwiverImageLoader.h"
#include "vtkVpTrackModel.h"

#include <vtkVgTrack.h>
Expand All @@ -26,8 +27,6 @@

#include <vital/types/object_track_set.h>

#include <arrows/vxl/image_io.h>

#include <atomic>
#include <functional>

Expand Down Expand Up @@ -132,7 +131,7 @@ class vpKwiverEmbeddedPipelineWorkerPrivate : public QThread

QStringList framePaths;

kwiver::arrows::vxl::image_io loader;
vpKwiverImageLoader loader;
kwiver::embedded_pipeline pipeline;

vpKwiverEmbeddedPipelineEndcap endcap;
Expand Down
Loading