Newer
Older
/**
* @brief Helper function to create status bar at the bottom of the window
*/
QFont f("Courier", 12, QFont::Bold); // Times Helvetica, Normal
statusBar()->setMaximumHeight(28);
statusBar()->showMessage(tr("Ready"));
statusBar()->addPermanentWidget(mStatusLabelStereo = new QLabel(" "));
statusBar()->addPermanentWidget(mStatusLabelTime = new QLabel(" "));
statusBar()->addPermanentWidget(mStatusLabelFPS = new QLabel(" "));
statusBar()->addPermanentWidget(mStatusPosRealHeight = new QDoubleSpinBox());
connect(mStatusPosRealHeight, SIGNAL(valueChanged(double)), this, SLOT(setStatusPosReal()));
statusBar()->addPermanentWidget(mStatusLabelPosReal = new QLabel(" "));
statusBar()->addPermanentWidget(mStatusLabelPos = new QLabel(" "));
statusBar()->addPermanentWidget(mStatusLabelColor = new QLabel(" "));
mStatusLabelStereo->setFont(f);
mStatusLabelStereo->setMinimumWidth(200);
mStatusLabelTime->setFont(f);
mStatusLabelTime->setMinimumWidth(200);
mStatusLabelFPS->setFont(f);
mStatusLabelFPS->setMinimumWidth(80);
mStatusLabelFPS->setAutoFillBackground(true);
mStatusLabelFPS->setToolTip("Click to adapt play rate to fps rate");
mStatusPosRealHeight->setRange(-999.9, 9999.9); // in cm
mStatusPosRealHeight->setDecimals(1);
mStatusPosRealHeight->setFont(f);
mStatusLabelPosReal->setFont(f);
mStatusLabelPosReal->setMinimumWidth(340);
mStatusLabelPos->setFont(f);
mStatusLabelPos->setMinimumWidth(100);
mStatusLabelColor->setFont(f);
mStatusLabelColor->setMinimumWidth(90);
mStatusLabelColor->setAutoFillBackground(true);
}
void Petrack::resetUI()
{
/// Reset all UI elements to default settings
/// Noetig damit alle UI Elemente, welche in der neu geladenen Projekt-Datei z.B. noch nicht vorhanden sind, auf
/// sinnvolle Werte gesetzt werden. Anderenfalls kommt es evtl. beim nacheinander laden verschiedener Projekte zu
/// einem Programmabsturz
///
return;
}
void Petrack::setStatusStereo(float x, float y, float z)
{
mStatusLabelStereo->setText(QString("x= novalue y= novalue z= novalue "));
mStatusLabelStereo->setText(
QString("x=%1cm y=%2cm z=%3cm ").arg(x, 6, 'f', 1).arg(y, 6, 'f', 1).arg(z, 6, 'f', 1));
{
mStatusLabelFPS->setText(QString("%1fps ").arg(mShowFPS, 5, 'f', 1));
QPalette pal = mStatusLabelFPS->palette(); // static moeglich?
double diff = mShowFPS - mAnimation->getFPS();
int opacity = mPlayerWidget->getPlayerSpeedLimited() ? 128 : 20;
if(diff < -6) // very slow ==> red
color.setRgb(200, 0, 0, opacity);
else if(diff < -2) // better ==> yellow
color.setRgb(200, 200, 0, opacity);
else if(diff > -2) // nearly ok ==> green
color.setRgb(0, 200, 0, opacity);
pal.setColor(QPalette::Window, color);
mStatusLabelFPS->setPalette(pal);
}
}
void Petrack::setShowFPS(double fps)
{
if((fps == 0.) || (mShowFPS == 0))
mShowFPS = mShowFPS * .9 + fps * .1; // glaetten durch Hinzunahme des alten Wertes
/**
* @brief Updates the FPS shown to the User
*
* This method calculates the FPS by remembering how long
* it has been since it was called last time. If skipped is
* true, it doesn't directly update the FPS since 2
* skipped frames have essentially a time delay of 0 between
* them, which would make calculations wonky.
*
* @param skipped True, if this is a skipped frame; default false
*/
void Petrack::updateShowFPS(bool skipped)
{
static QElapsedTimer lastTime;
lastTime.invalidate();
int numFrames = skippedFrames > 0 ? skippedFrames + 1 : 1;
setShowFPS(numFrames * 1000. / lastTime.elapsed());
}
}
lastTime.start();
}
}
// ohne neue positionsangabe, sinnvoll, wenn berechnungsweise sich in getPosReal geaendert hat
// gebraucht in control.cpp
void Petrack::setStatusPosReal() // pos in cm
{
setStatusPosReal(mImageItem->getPosReal(mMousePosOnImage, getStatusPosRealHeight()));
void Petrack::setStatusPosReal(const QPointF &pos) // pos in cm
{
QChar deg(0xB0);
QString labelText = QString(" cm from ground:%1cm,%2cm,%3")
.arg(pos.x(), 6, 'f', 1)
.arg(pos.y(), 6, 'f', 1)
.arg(
getImageItem()->getAngleToGround(
mMousePosOnImage.x(), mMousePosOnImage.y(), getStatusPosRealHeight()),
5,
'f',
1);
labelText.append(deg);
mStatusLabelPosReal->setText(labelText);
}
}
void Petrack::setStatusPos(const QPoint &pos) // pos in pixel
{
mStatusLabelPos->setText(QString("%1x%2").arg(pos.x(), 4).arg(pos.y(), 4));
}
void Petrack::setStatusColor(const QRgb &col)
{
QString s("#%1%2%3"); // static moeglich?
s = s.arg(qRed(col), 2, 16, QChar('0')).arg(qGreen(col), 2, 16, QChar('0')).arg(qBlue(col), 2, 16, QChar('0'));
if((qRed(col) + qGreen(col) + qBlue(col)) / 3 < 128)
mStatusLabelColor->setText(QString("<font color=\"#ffffff\"> %1</font>").arg(s));
mStatusLabelColor->setText(QString("<font color=\"#000000\"> %1</font>").arg(s));
QPalette pal = mStatusLabelColor->palette(); // static moeglich?
QColor color(qRed(col), qGreen(col), qBlue(col));
pal.setColor(QPalette::Window, color);
mStatusLabelColor->setPalette(pal);
mControlWidget->getColorPlot()->setCursor(color);
mControlWidget->getColorPlot()->replot();
}
void Petrack::setStatusColor()
{
QPointF pos = getMousePosOnImage();
if(pos.x() >= 0 && pos.x() < mImage->width() && pos.y() > 0 && pos.y() < mImage->height())
setStatusColor(mImage->pixel(pos.toPoint()));
}
}
double Petrack::getStatusPosRealHeight()
{
/**
* @brief Reads (and applies) settings form platform-independent persistent storage
*
* The saved size and position of the application window get reconstructed. As well as
* the options about antialiasing and the usage of OpenGL.
* mSeqFileName and mProFileName get set, so the "Open Project" and "Open Sequence"
* dialogues start at correct folder. The old project/sequence is NOT actually loaded.
*/
void Petrack::readSettings()
{
QSettings settings("Forschungszentrum Juelich GmbH", "PeTrack by Maik Boltes, Daniel Salden");
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
mAntialiasAct->setChecked(settings.value("antialias", false).toBool());
mOpenGLAct->setChecked(settings.value("opengl", false).toBool());
mSeqFileName = settings.value("seqFileName", QDir::currentPath()).toString();
setProFileName(settings.value("proFilePath", QDir::currentPath()).toString());
// nicht ganz sauber, da so immer schon zu anfang in calib file list etwas drin steht und somit auto ausgefuehrt
// werden kann wird aber beim ersten openCalib... ueberschrieben
mAutoCalib.addCalibFile(settings.value("calibFile", QDir::currentPath()).toString());
resize(size);
move(pos);
antialias();
opengl();
mSplitter->restoreState(settings.value("controlSplitterSizes").toByteArray());
/**
* @brief Writes persistent setting.
* @see Petrack::readSettings
*/
void Petrack::writeSettings()
{
QSettings settings("Forschungszentrum Juelich GmbH", "PeTrack by Maik Boltes, Daniel Salden");
settings.setValue("pos", pos());
settings.setValue("size", size());
settings.setValue("antialias", mAntialiasAct->isChecked());
settings.setValue("opengl", mOpenGLAct->isChecked());
settings.setValue("seqFileName", mSeqFileName);
settings.setValue("proFilePath", QFileInfo(mProFileName).path()); // nur path, damit bei saveCurrentProject
if(!mAutoCalib.isEmptyCalibFiles()) //! mCalibFiles.isEmpty()
settings.setValue("controlSplitterSizes", mSplitter->saveState());
int ret = PWarning(
this,
tr("PeTrack"),
tr("Do you want to save "
"the current project?\n"
"Be sure to save trajectories, background "
"and 3D calibration point separately!"),
PMessageBox::StandardButton::Yes | PMessageBox::StandardButton::No | PMessageBox::StandardButton::Cancel,
PMessageBox::StandardButton::Yes);
if(ret == PMessageBox::StandardButton::Yes)
else if(ret == PMessageBox::StandardButton::Cancel)
}
void Petrack::closeEvent(QCloseEvent *event)
{
/**
* @brief Sets the mMousePosOnImage member variable and displayed pixel/real coordinates
*
* Gets called from ImageItem::hoverMoveEvent() and enables an easy access
* to the mouse position.
* @param pos Position of mouse cursor in image pixel coordinates
*/
{
mMousePosOnImage = pos;
setStatusPosReal(mImageItem->getPosReal(pos, getStatusPosRealHeight()));
// pixel coordinate
QPoint pos1((int) (pos.x()) + 1, (int) (pos.y()) + 1);
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
void Petrack::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Left:
mPlayerWidget->frameBackward();
break;
case Qt::Key_Right:
mPlayerWidget->frameForward();
break;
case Qt::Key_Down:
mViewWidget->zoomOut(1);
break;
case Qt::Key_Up:
mViewWidget->zoomIn(1);
break;
case Qt::Key_Space:
// space wird von buttons, wenn focus drauf ist als Aktivierung vorher abgegriffen und nicht durchgereicht
mPlayerWidget->togglePlayPause();
break;
case Qt::Key_D:
break;
default:;
}
}
void Petrack::mousePressEvent(QMouseEvent *event)
{
// mouse click in fps status label ?
if(event->pos().x() >= mStatusLabelFPS->pos().x() &&
event->pos().x() <= mStatusLabelFPS->pos().x() + mStatusLabelFPS->width())
mPlayerWidget->togglePlayerSpeedLimited();
const QString &Petrack::getLastTrackerExport() const
{
return mLastTrackerExport;
}
void Petrack::setLastTrackerExport(const QString &newLastTrackerExport)
{
mLastTrackerExport = newLastTrackerExport;
}
/// update control widget, if image size changed (especially because of changing border)
void Petrack::updateControlImage(cv::Mat &img)
{
// auch moeglich hoehe und breite von bild stat border veraenderungen zu checken
static int lastBorderSize = -1;
if(lastBorderSize != -1)
diffBorderSize = getImageBorderSize() - lastBorderSize;
lastBorderSize = getImageBorderSize();
const int imgWidth = img.cols;
const int imgHeight = img.rows;
mControlWidget->imageSizeChanged(imgWidth, imgHeight, diffBorderSize);
void Petrack::importTracker(QString dest) // default = ""
dest = QFileDialog::getOpenFileName(
this,
tr("Select file for importing tracking pathes"),
lastFile,
tr("PeTrack tracker (*.trc *.txt);;All files (*.*)"));
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
// errorstring ist je nach Betriebssystem in einer anderen Sprache!!!!
PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2").arg(dest).arg(file.errorString()));
setTrackChanged(true); // flag changes of track parameters
mTracker->reset();
QTextStream in(&file);
TrackPerson tp;
bool ok; // shows if int stands in first line - that was in the first version of trc file
sz = firstLine.toInt(&ok);
if(!ok)
if(firstLine.contains("version 4", Qt::CaseInsensitive))
{
trcVersion = 4;
}
else if(firstLine.contains("version 3", Qt::CaseInsensitive))
else if(firstLine.contains("version 2", Qt::CaseInsensitive))
}
else
SPDLOG_ERROR("wrong header while reading TRC file.");
QMessageBox::critical(
this,
tr("PeTrack"),
tr("Could not import tracker:\nNot supported trc version in file: %1.").arg(dest));
Schrödter, Tobias
committed
return;
if((sz > 0) && (mPersonStorage.nbPersons() != 0))
SPDLOG_WARN("overlapping trajectories will be joined not until tracking adds new TrackPoints.");
mPersonStorage.addPerson(tp);
tp.clear(); // loeschen, sonst immer weitere pfade angehangen werden
mControlWidget->setTrackNumberAll(QString("%1").arg(mPersonStorage.nbPersons()));
mControlWidget->setTrackShowOnlyNr(static_cast<int>(MAX(mPersonStorage.nbPersons(), 1)));
mControlWidget->setTrackNumberVisible(
QString("%1").arg(mPersonStorage.visible(mAnimation->getCurrentFrameNum())));
mControlWidget->replotColorplot();
SPDLOG_INFO("import {} ({} person(s), file version {})", dest, sz, trcVersion);
mTrcFileName =
dest; // fuer Project-File, dann koennte track path direkt mitgeladen werden, wenn er noch da ist
}
else if(dest.right(4) == ".txt") // 3D Koordinaten als Tracking-Daten importieren Zeilenformat: Personennr,
// Framenr, x, y, z
PWarning(
this,
tr("PeTrack"),
tr("Are you sure you want to import 3D data from TXT-File? You have to make sure that the coordinate "
"system now is exactly at the same position and orientation than at export time!"));
QFile file(dest);
// size of person list
int sz = 0;
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
// errorstring ist je nach Betriebssystem in einer anderen Sprache!!!!
PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2").arg(dest).arg(file.errorString()));
setTrackChanged(true); // flag changes of track parameters
mTracker->reset();
QTextStream in(&file);
TrackPerson tp;
bool exec_once_flag = false;
double conversionFactorTo_cm = 1.0;
int personNr = -1, frameNr = -1, current_personNr = 1;
float x, y, z;
{
// Falls Datei am Ende letzte Person abspeichern und Lese-Schleife beenden
mPersonStorage.addPerson(tp);
++sz;
tp.clear();
break;
}
line = in.readLine();
// Kommentare ueberlesen
if(line.startsWith("#", Qt::CaseInsensitive))
if((!exec_once_flag) && (!headerline.contains("cm")))
exec_once_flag = true;
PWarning(
this,
tr("PeTrack"),
tr("PeTrack will interpret position data as unit [m]. No header with [cm] found."));
}
QTextStream stream(&line);
// Zeile als Stream einlesen Format: [id frame x y z]
stream >> personNr >> frameNr >> x >> y >> z;
// convert data to cm
x = x * conversionFactorTo_cm;
y = y * conversionFactorTo_cm;
z = z * conversionFactorTo_cm;
// 3-dimensionale Berechnung/Anzeige des Punktes
if(mControlWidget->getCalibCoordDimension() == 0)
p2d = mExtrCalibration.getImagePoint(cv::Point3f(x, y, z));
}
// 2-dimensionale Berechnung/Anzeige des Punktes
else
{
QPointF pos = mImageItem->getPosImage(QPointF(x, y), z);
p2d.x = pos.x();
p2d.y = pos.y();
tPoint = TrackPoint(Vec2F(p2d.x, p2d.y), 100);
tPoint.setSp(
x,
y,
-mControlWidget->getCalibExtrTrans3() -
z); // fuer den Abstand zur Kamera in z-Richtung wie bei einer Stereokamera
mPersonStorage.addPerson(tp);
++sz;
current_personNr++;
tp.clear();
}
// TrackPerson leer ? ==> Neue TrackPerson erstellen
{
tp = TrackPerson(personNr, frameNr, tPoint);
tp.setFirstFrame(frameNr);
tp.setHeight(z);
}
// TrackPoint an TrackPerson anhaengen
else
{
tp.setLastFrame(frameNr);
tp.append(tPoint);
}
}
mControlWidget->setTrackNumberAll(QString("%1").arg(mPersonStorage.nbPersons()));
mControlWidget->setTrackShowOnlyNr(static_cast<int>(MAX(mPersonStorage.nbPersons(), 1)));
mControlWidget->setTrackNumberVisible(
QString("%1").arg(mPersonStorage.visible(mAnimation->getCurrentFrameNum())));
mControlWidget->replotColorplot();
SPDLOG_INFO("import {} ({} person(s))", dest, sz);
mTrcFileName =
dest; // fuer Project-File, dann koennte track path direkt mitgeladen werden, wenn er noch da ist
PCritical(this, tr("PeTrack"), tr("Cannot load %1 maybe because of wrong file extension.").arg(dest));
}
lastFile = dest;
}
}
void Petrack::testTracker()
{
static int idx = 0; // index in Fehlerliste, die als letztes angesprungen wurde
mPersonStorage.checkPlausibility(
mControlWidget->isTestEqualChecked(),
mControlWidget->isTestVelocityChecked(),
mControlWidget->isTestInsideChecked(),
mControlWidget->isTestLengthChecked());
mControlWidget->setTrackShowOnly(Qt::Checked);
mControlWidget->setTrackShowOnlyNr(pers[idx]);
++idx;
}
}
int Petrack::calculateRealTracker()
{
bool autoCorrectOnlyExport = (mReco.getRecoMethod() == reco::RecognitionMethod::MultiColor) && // multicolor
mMultiColorMarkerWidget->autoCorrect->isChecked() &&
mMultiColorMarkerWidget->autoCorrectOnlyExport->isChecked();
int anz = mTrackerReal->calculate(
mTracker,
mImageItem,
mControlWidget->getColorPlot(),
mControlWidget->getAnaMissingFrames(),
mStereoWidget->stereoUseForExport->isChecked(),
mControlWidget->getTrackAlternateHeight(),
mControlWidget->getCameraAltitude(),
mStereoWidget->stereoUseCalibrationCenter->isChecked(),
mControlWidget->isExportElimTpChecked(),
mControlWidget->isExportElimTrjChecked(),
mControlWidget->isExportSmoothChecked(),
mControlWidget->isExportViewDirChecked(),
mControlWidget->isExportAngleOfViewChecked(),
mControlWidget->isExportMarkerIDChecked(),
void Petrack::exportTracker(QString dest) // default = ""
Schrödter, Tobias
committed
try
Schrödter, Tobias
committed
if(!mTracker)
{
return;
}
QFileDialog fileDialog(
this,
Schrödter, Tobias
committed
tr("Select file for exporting tracking paths"),
tr("Tracker (*.*);;Petrack tracker (*.trc);;Text (*.txt);;Text for gnuplot(*.dat);;XML Travisto "
"(*.trav);;All supported types (*.txt *.trc *.dat *.trav *.);;All files (*.*)"));
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setDefaultSuffix("");
Schrödter, Tobias
committed
if(dest.isEmpty())
{
return;
}
Schrödter, Tobias
committed
QList<int> pers, frame;
bool autoCorrectOnlyExport = (mReco.getRecoMethod() == reco::RecognitionMethod::MultiColor) && // multicolor
mMultiColorMarkerWidget->autoCorrect->isChecked() &&
mMultiColorMarkerWidget->autoCorrectOnlyExport->isChecked();
if(dest.right(4) == ".trc")
{
QTemporaryFile file;
Schrödter, Tobias
committed
if(!file.open() /*!file.open(QIODevice::WriteOnly | QIODevice::Text)*/)
{
PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(dest).arg(file.errorString()));
return;
}
QProgressDialog progress(
"Export TRC-File", nullptr, 0, static_cast<int>(mPersonStorage.nbPersons() + 1), this->window());
progress.setWindowTitle("Export .trc-File");
progress.setWindowModality(Qt::WindowModal);
progress.setVisible(true);
progress.setValue(0);
progress.setLabelText(QString("Export tracking data ..."));
Schrödter, Tobias
committed
qApp->processEvents();
Schrödter, Tobias
committed
trcVersion = 4;
Schrödter, Tobias
committed
SPDLOG_INFO(
"export tracking data to {} ({} person(s), file version {})",
dest,
mPersonStorage.nbPersons(),
trcVersion);
QTextStream out(&file);
out << "version " << trcVersion << Qt::endl;
out << mPersonStorage.nbPersons() << Qt::endl;
const auto &persons = mPersonStorage.getPersons();
for(size_t i = 0; i < persons.size(); ++i)
{
qApp->processEvents();
progress.setLabelText(
QString("Export person %1 of %2 ...").arg(i + 1).arg(mPersonStorage.nbPersons()));
progress.setValue(static_cast<int>(i + 1));
out << persons[i] << Qt::endl;
}
file.flush();
file.close();
progress.setLabelText(QString("Save file ..."));
qApp->processEvents();
Schrödter, Tobias
committed
if(QFile::exists(dest))
{
QFile::remove(dest);
}
Schrödter, Tobias
committed
if(!file.copy(dest))
{
PCritical(
this,
tr("PeTrack"),
tr("Could not export tracking data.\n"
"Please try again!"));
}
else
{
statusBar()->showMessage(tr("Saved tracking data to %1.").arg(dest), 5000);
}
Schrödter, Tobias
committed
progress.setValue(static_cast<int>(mPersonStorage.nbPersons() + 1));
Schrödter, Tobias
committed
SPDLOG_INFO("finished.");
mAutosave.resetTrackPersonCounter();
mTrcFileName =
dest; // fuer Project-File, dann koennte track path direkt mitgeladen werden, wenn er// noch da ist
Schrödter, Tobias
committed
}
else if(dest.right(4) == ".txt")
{
QTemporaryFile file;
Schrödter, Tobias
committed
if(!file.open())
{
PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(dest).arg(file.errorString()));
return;
}
Schrödter, Tobias
committed
SPDLOG_INFO("export tracking data to {} ({} person(s))...", dest, mPersonStorage.nbPersons());
// recalcHeight true, wenn personenhoehe ueber trackpoints neu berechnet werden soll (z.b. um
Schrödter, Tobias
committed
// waehrend play mehrfachberuecksichtigung von punkten auszuschliessen, aenderungen in altitude neu
// in berechnung einfliessen zu lassen)
if(mControlWidget->isTrackRecalcHeightChecked())
if(mControlWidget->getCalibCoordDimension() == 0) // 3D
{
; // Nothing to be done because z already the right height
}
else // 2D
{
mPersonStorage.recalcHeight(mControlWidget->getCameraAltitude());
}
mTrackerReal->calculate(
this,
mTracker,
mImageItem,
mControlWidget->getColorPlot(),
mMissingFrames,
getImageBorderSize(),
mControlWidget->isTrackMissingFramesChecked(),
mStereoWidget->stereoUseForExport->isChecked(),
mControlWidget->getTrackAlternateHeight(),
mControlWidget->getCameraAltitude(),
mStereoWidget->stereoUseCalibrationCenter->isChecked(),
mControlWidget->isExportElimTpChecked(),
mControlWidget->isExportElimTrjChecked(),
mControlWidget->isExportSmoothChecked(),
mControlWidget->isExportViewDirChecked(),
mControlWidget->isExportAngleOfViewChecked(),
mControlWidget->isExportMarkerIDChecked(),
autoCorrectOnlyExport);
Schrödter, Tobias
committed
QTextStream out(&file);
Schrödter, Tobias
committed
out << "# PeTrack project: " << QFileInfo(getProFileName()).fileName() << Qt::endl;
out << "# raw trajectory file: " << QFileInfo(getTrackFileName()).fileName() << Qt::endl;
out << "# framerate: " << mAnimation->getFPS() << " fps" << Qt::endl;
Schrödter, Tobias
committed
if(mControlWidget->isExportCommentChecked())
{
out << "# personal information:" << Qt::endl;
out << "# ID| Comment" << Qt::endl;
Schrödter, Tobias
committed
// std out
SPDLOG_INFO("Printing comment table...");
SPDLOG_INFO("ID | Comment");
SPDLOG_INFO("----|----------------");
Schrödter, Tobias
committed
for(int i = 0; i < static_cast<int>(mPersonStorage.nbPersons()); ++i)
{
auto commentSplit = mPersonStorage.at(i).comment().split("\n", Qt::KeepEmptyParts);
out << "#" << qSetFieldWidth(3) << (i + 1) << qSetFieldWidth(0) << "|" << commentSplit.at(0)
<< Qt::endl;
SPDLOG_INFO("{:04d}|{}", (i + 1), commentSplit.at(0));
commentSplit.pop_front();
for(const QString &line : commentSplit)
Schrödter, Tobias
committed
out << "#" << qSetFieldWidth(3) << " " << qSetFieldWidth(0) << "|" << line << Qt::endl;
SPDLOG_INFO(" |{}", line);
Schrödter, Tobias
committed
}
mTrackerReal->exportTxt(
out,
mControlWidget->getTrackAlternateHeight(),
mStereoWidget->stereoUseForExport->isChecked(),
mControlWidget->isExportViewDirChecked(),
mControlWidget->isExportAngleOfViewChecked(),
mControlWidget->isExportUseMeterChecked(),
mControlWidget->isExportMarkerIDChecked());
// out << *mTrackerReal;
file.flush();
file.close();
Schrödter, Tobias
committed
if(QFile::exists(dest))
{
QFile::remove(dest);
}
if(!file.copy(dest))
{
PCritical(
this,
tr("PeTrack"),
tr("Could not export tracking data.\n"
"Please try again!"));
}
else
{
statusBar()->showMessage(tr("Saved tracking data to %1.").arg(dest), 5000);
}
SPDLOG_INFO("finished");
}
else if(dest.right(4) == ".dat")
{
QTemporaryFile fileDat;
Schrödter, Tobias
committed
if(!fileDat.open()) //! fileDat.open(QIODevice::WriteOnly | QIODevice::Text))
{
PCritical(this, tr("PeTrack"), tr("Cannot open %1:\n%2.").arg(dest).arg(fileDat.errorString()));
return;
Schrödter, Tobias
committed
// recalcHeight true, wenn personenhoehe ueber trackpoints neu berechnet werden soll (z.b. um
// waehrend play mehrfachberuecksichtigung von punkten auszuschliessen, aenderungen in altitude neu
// in berechnung einfliessen zu lassen)
if(mControlWidget->isTrackRecalcHeightChecked())
Schrödter, Tobias
committed
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
mPersonStorage.recalcHeight(mControlWidget->getCameraAltitude());
}
mTrackerReal->calculate(
this,
mTracker,
mImageItem,
mControlWidget->getColorPlot(),
mMissingFrames,
getImageBorderSize(),
mControlWidget->isTrackMissingFramesChecked(),
mStereoWidget->stereoUseForExport->isChecked(),
mControlWidget->getTrackAlternateHeight(),
mControlWidget->getCameraAltitude(),
mStereoWidget->stereoUseCalibrationCenter->isChecked(),
mControlWidget->isExportElimTpChecked(),
mControlWidget->isExportElimTrjChecked(),
mControlWidget->isExportSmoothChecked(),
mControlWidget->isExportViewDirChecked(),
mControlWidget->isExportAngleOfViewChecked(),
mControlWidget->isExportMarkerIDChecked(),
autoCorrectOnlyExport);
SPDLOG_INFO("export tracking data to {} ({} person(s))...", dest, mPersonStorage.nbPersons());
QTextStream outDat(&fileDat);
mTrackerReal->exportDat(
outDat, mControlWidget->getTrackAlternateHeight(), mStereoWidget->stereoUseForExport->isChecked());
fileDat.flush();
fileDat.close();
if(QFile::exists(dest))
{
QFile::remove(dest);
}
Schrödter, Tobias
committed
if(!fileDat.copy(dest))
{
PCritical(
Schrödter, Tobias
committed
tr("PeTrack"),
tr("Could not export tracking data.\n"
"Please try again!"));
}
else
{
statusBar()->showMessage(tr("Saved tracking data to %1.").arg(dest), 5000);
}