Newer
Older
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
mImage->fill(QColor::fromRgb(255, 255, 255));
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
mImageItem->setImage(mImage);
mLogoItem->show();
}
mStatusPosRealHeight->setValue(180.0);
/// calibration params
/// image filters
mControlWidget->filterBrightContrast->setCheckState(Qt::Unchecked);
mControlWidget->filterBrightParam->setValue(0);
mControlWidget->filterContrastParam->setValue(0);
mControlWidget->filterBorder->setCheckState(Qt::Unchecked);
mControlWidget->filterBorderParamSize->setValue(0);
QColor defaultBorder = Qt::black;
getBorderFilter()->getBorderColR()->setValue(defaultBorder.red());
getBorderFilter()->getBorderColG()->setValue(defaultBorder.green());
getBorderFilter()->getBorderColB()->setValue(defaultBorder.blue());
mControlWidget->filterBg->setCheckState(Qt::Unchecked);
mControlWidget->filterBgDeleteNumber->setValue(3);
mControlWidget->filterBgDeleteTrj->setCheckState(Qt::Checked);
mControlWidget->filterBgShow->setCheckState(Qt::Unchecked);
mControlWidget->filterBgUpdate->setCheckState(Qt::Unchecked);
getBackgroundFilter()->setFilename(nullptr);
getBackgroundFilter()->reset();
mControlWidget->filterSwap->setCheckState(Qt::Unchecked);
mControlWidget->filterSwapH->setCheckState(Qt::Unchecked);
mControlWidget->filterSwapV->setCheckState(Qt::Unchecked);
/// intrinsic params
mControlWidget->apply->setCheckState(Qt::Unchecked);
mControlWidget->fx->setValue(1000);
mControlWidget->fy->setValue(1000);
mControlWidget->cx->setValue(960);
mControlWidget->cx->setMinimum(0);
mControlWidget->cx->setMaximum(mControlWidget->cx->value() * 2);
mControlWidget->cy->setValue(540);
mControlWidget->cx->setMinimum(0);
mControlWidget->cy->setMaximum(mControlWidget->cy->value() * 2);
mControlWidget->r2->setValue(0);
mControlWidget->r4->setValue(0);
mControlWidget->r6->setValue(0);
mControlWidget->tx->setValue(0);
mControlWidget->ty->setValue(0);
mControlWidget->k4->setValue(0);
mControlWidget->k5->setValue(0);
mControlWidget->k6->setValue(0);
mControlWidget->s1->setValue(0);
mControlWidget->s2->setValue(0);
mControlWidget->s3->setValue(0);
mControlWidget->s4->setValue(0);
mControlWidget->taux->setValue(0);
mControlWidget->tauy->setValue(0);
mControlWidget->quadAspectRatio->setCheckState(Qt::Unchecked);
mControlWidget->fixCenter->setCheckState(Qt::Unchecked);
mControlWidget->tangDist->setCheckState(Qt::Checked);
getAutoCalib()->setBoardSizeX(6);
getAutoCalib()->setBoardSizeY(8);
getAutoCalib()->setSquareSize(5.0);
getAutoCalib()->setCalibFiles(QStringList());
/// extrinsic params
mControlWidget->trans1->setValue(0);
mControlWidget->trans2->setValue(0);
mControlWidget->trans3->setValue(-500);
mControlWidget->rot1->setValue(0);
mControlWidget->rot2->setValue(0);
mControlWidget->rot3->setValue(0);
getExtrCalibration()->setExtrCalibFile(nullptr);
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
/// coord system
mControlWidget->coordShow->setCheckState(Qt::Unchecked);
mControlWidget->coordFix->setCheckState(Qt::Unchecked);
mControlWidget->coordTab->setCurrentIndex(0);
// 3D
mControlWidget->coord3DTransX->setValue(0);
mControlWidget->coord3DTransY->setValue(0);
mControlWidget->coord3DTransZ->setValue(0);
mControlWidget->coord3DAxeLen->setValue(200);
mControlWidget->coord3DSwapX->setCheckState(Qt::Unchecked);
mControlWidget->coord3DSwapY->setCheckState(Qt::Unchecked);
mControlWidget->coord3DSwapZ->setCheckState(Qt::Unchecked);
mControlWidget->extCalibPointsShow->setCheckState(Qt::Unchecked);
mControlWidget->extVanishPointsShow->setCheckState(Qt::Unchecked);
// 2D
mControlWidget->coordTransX->setValue(0);
mControlWidget->coordTransY->setValue(0);
mControlWidget->coordRotate->setValue(0);
mControlWidget->coordScale->setValue(100);
mControlWidget->coordAltitude->setValue(535);
mControlWidget->coordUnit->setValue(100);
mControlWidget->coordUseIntrinsic->setCheckState(Qt::Unchecked);
/// alignment grid
mControlWidget->gridShow->setCheckState(Qt::Unchecked);
mControlWidget->gridFix->setCheckState(Qt::Unchecked);
mControlWidget->gridTab->setCurrentIndex(0);
// 3D
mControlWidget->grid3DTransX->setValue(0);
mControlWidget->grid3DTransY->setValue(0);
mControlWidget->grid3DTransZ->setValue(0);
mControlWidget->grid3DResolution->setValue(100);
// 2D
mControlWidget->gridTransX->setValue(0);
mControlWidget->gridTransY->setValue(0);
mControlWidget->gridRotate->setValue(0);
mControlWidget->gridScale->setValue(100);
///
/// recognition params
///
mControlWidget->performRecognition->setCheckState(Qt::Unchecked);
mControlWidget->recoStep->setValue(1);
// region of interest
mControlWidget->roiFix->setCheckState(Qt::Unchecked);
mControlWidget->roiShow->setCheckState(Qt::Unchecked);
getRecoRoiItem()->setRect(0, 0, 0, 0);
// marker, default multicolor marker (until 11/2016 hermes marker)
mControlWidget->recoMethod->setCurrentIndex(
mControlWidget->recoMethod->findData(QVariant::fromValue(reco::RecognitionMethod::MultiColor)));
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
mControlWidget->markerBrightness->setValue(100);
mControlWidget->markerIgnoreWithout->setCheckState(Qt::Checked);
// size and color
mControlWidget->recoShowColor->setCheckState(Qt::Checked);
mControlWidget->recoAutoWB->setCheckState(Qt::Checked);
mControlWidget->recoColorX->setCurrentIndex(0);
mControlWidget->recoColorY->setCurrentIndex(1);
mControlWidget->recoColorZ->setValue(255);
mControlWidget->recoGreyLevel->setValue(50);
mControlWidget->recoSymbolSize->setValue(10);
// map
mControlWidget->recoColorModel->setCurrentIndex(0);
mControlWidget->colorPlot->getMapItem()->delMaps();
mControlWidget->mapNr->setValue(0);
mControlWidget->mapNr->setMinimum(0);
mControlWidget->mapNr->setMaximum(0);
mControlWidget->mapX->setValue(0);
mControlWidget->mapY->setValue(0);
mControlWidget->mapW->setValue(0);
mControlWidget->mapH->setValue(0);
mControlWidget->mapColor->setCheckState(Qt::Checked);
mControlWidget->mapHeight->setValue(180);
mControlWidget->mapDefaultHeight->setValue(180);
///
/// tracking params
///
mControlWidget->trackOnlineCalc->setCheckState(Qt::Checked);
mControlWidget->trackRepeat->setCheckState(Qt::Checked);
mControlWidget->trackRepeatQual->setValue(50);
mControlWidget->trackExtrapolation->setCheckState(Qt::Checked);
mControlWidget->trackMerge->setCheckState(Qt::Unchecked);
mControlWidget->trackOnlySelected->setCheckState(Qt::Checked);
getTrackRoiItem()->setRect(0, 0, 0, 0);
// export options
mControlWidget->trackMissingFrames->setCheckState(Qt::Checked);
mControlWidget->trackRecalcHeight->setCheckState(Qt::Checked);
mControlWidget->trackAlternateHeight->setCheckState(Qt::Unchecked);
mControlWidget->exportElimTp->setCheckState(Qt::Unchecked);
mControlWidget->exportElimTrj->setCheckState(Qt::Unchecked);
mControlWidget->exportSmooth->setCheckState(Qt::Checked);
mControlWidget->exportViewDir->setCheckState(Qt::Unchecked);
mControlWidget->exportAngleOfView->setCheckState(Qt::Unchecked);
mControlWidget->exportUseM->setCheckState(Qt::Unchecked);
mControlWidget->exportComment->setCheckState(Qt::Unchecked);
mControlWidget->exportMarkerID->setCheckState(Qt::Unchecked);
// test options
mControlWidget->testEqual->setCheckState(Qt::Checked);
mControlWidget->testVelocity->setCheckState(Qt::Checked);
mControlWidget->testInside->setCheckState(Qt::Checked);
mControlWidget->testLength->setCheckState(Qt::Checked);
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
// search region
mControlWidget->trackRegionScale->setValue(16);
mControlWidget->trackRegionLevels->setValue(3);
mControlWidget->trackErrorExponent->setValue(0);
mControlWidget->trackShowSearchSize->setCheckState(Qt::Unchecked);
// path params
mControlWidget->trackShow->setCheckState(Qt::Checked);
mControlWidget->trackFix->setCheckState(Qt::Unchecked);
mControlWidget->trackShowOnlyVisible->setCheckState(Qt::Unchecked);
mControlWidget->trackShowOnly->setCheckState(Qt::Unchecked);
mControlWidget->trackShowOnlyNr->setValue(1);
mControlWidget->trackShowOnlyList->setCheckState(Qt::Unchecked);
mControlWidget->trackShowOnlyNrList->setEnabled(false);
mControlWidget->trackShowOnlyListButton->setEnabled(false);
mControlWidget->trackShowCurrentPoint->setCheckState(Qt::Checked);
mControlWidget->trackShowPoints->setCheckState(Qt::Unchecked);
mControlWidget->trackShowPath->setCheckState(Qt::Checked);
mControlWidget->trackShowColColor->setCheckState(Qt::Checked);
mControlWidget->trackShowColorMarker->setCheckState(Qt::Checked);
mControlWidget->trackShowNumber->setCheckState(Qt::Checked);
mControlWidget->trackShowGroundPosition->setCheckState(Qt::Unchecked);
mControlWidget->trackShowGroundPath->setCheckState(Qt::Unchecked);
mControlWidget->setTrackPathColor(Qt::red);
mControlWidget->setTrackGroundPathColor(Qt::green);
mControlWidget->trackHeadSized->setCheckState(Qt::Checked);
mControlWidget->trackCurrentPointSize->setValue(60);
mControlWidget->trackPointSize->setValue(7);
mControlWidget->trackPathWidth->setValue(2);
mControlWidget->trackColColorSize->setValue(11);
mControlWidget->trackColorMarkerSize->setValue(14);
mControlWidget->trackNumberSize->setValue(14);
mControlWidget->trackGroundPositionSize->setValue(1);
mControlWidget->trackGroundPathSize->setValue(1);
mControlWidget->trackShowPointsColored->setCheckState(Qt::Checked);
mControlWidget->trackNumberBold->setCheckState(Qt::Checked);
mControlWidget->trackShowBefore->setValue(15);
mControlWidget->trackShowAfter->setValue(15);
/// analysis params
mControlWidget->anaMissingFrames->setCheckState(Qt::Checked);
mControlWidget->anaMarkAct->setCheckState(Qt::Unchecked);
mControlWidget->anaStep->setValue(25);
mControlWidget->anaConsiderX->setCheckState(Qt::Unchecked);
mControlWidget->anaConsiderY->setCheckState(Qt::Checked);
mControlWidget->anaConsiderAbs->setCheckState(Qt::Unchecked);
mControlWidget->anaConsiderRev->setCheckState(Qt::Unchecked);
mControlWidget->showVoronoiCells->setCheckState(Qt::Unchecked);
}
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);
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
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;
int diffBorderSize = 0;
int iW = img.cols;
int iH = img.rows;
// wird auch nochmal in ImageWidget gemacht, aber ist hier frueher noetig
double cX = mControlWidget->getCalibCxValue(); // merken, da min/max value verandernkann wenn aus dem rahmen
double cY = mControlWidget->getCalibCyValue();
mControlWidget->setCalibCxMin(0 /*iW/2.-50.*/);
mControlWidget->setCalibCyMin(0 /*iH/2.-50.*/);
if(mControlWidget->fixCenter->checkState() == Qt::Checked)
mControlWidget->setCalibCxValue((iW - 1) / 2.);
mControlWidget->setCalibCyValue((iH - 1) / 2.);
diffBorderSize = getImageBorderSize() - lastBorderSize;
mControlWidget->setCalibCxValue(cX + diffBorderSize);
mControlWidget->setCalibCyValue(cY + 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
debout << "Error: wrong header while reading TRC file." << std::endl;
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))
debout << "Warning: Overlapping trajectories will be joined not until tracking adds new trackpoints."
<< std::endl;
mPersonStorage.addPerson(tp);
tp.clear(); // loeschen, sonst immer weitere pfade angehangen werden
mControlWidget->trackNumberAll->setText(QString("%1").arg(mPersonStorage.nbPersons()));
mControlWidget->trackShowOnlyNr->setMaximum(MAX(mPersonStorage.nbPersons(), 1));
mControlWidget->trackNumberVisible->setText(
QString("%1").arg(mPersonStorage.visible(mAnimation->getCurrentFrameNum())));
debout << "import " << dest << " (" << sz << " person(s), file version " << trcVersion << ")" << std::endl;
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->trackNumberAll->setText(QString("%1").arg(mPersonStorage.nbPersons()));
mControlWidget->trackShowOnlyNr->setMaximum(MAX(mPersonStorage.nbPersons(), 1));
mControlWidget->trackNumberVisible->setText(
QString("%1").arg(mPersonStorage.visible(mAnimation->getCurrentFrameNum())));
debout << "import " << dest << " (" << sz << " person(s) )" << std::endl;
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(
pers,
frame,
mControlWidget->testEqual->isChecked(),
mControlWidget->testVelocity->isChecked(),
mControlWidget->testInside->isChecked(),
mControlWidget->testLength->isChecked());
if(pers.length() <= idx)
{
mControlWidget->trackShowOnly->setCheckState(Qt::Checked);
mControlWidget->trackShowOnlyNr->setValue(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(),
getImageBorderSize(),
mControlWidget->anaMissingFrames->checkState(),
mStereoWidget->stereoUseForExport->isChecked(),
mControlWidget->trackAlternateHeight->checkState(),
mControlWidget->coordAltitude->value(),
mStereoWidget->stereoUseCalibrationCenter->isChecked(),
mControlWidget->exportElimTp->isChecked(),
mControlWidget->exportElimTrj->isChecked(),
mControlWidget->exportSmooth->isChecked(),
mControlWidget->exportViewDir->isChecked(),
mControlWidget->exportAngleOfView->isChecked(),
mControlWidget->exportMarkerID->isChecked(),
autoCorrectOnlyExport);
void Petrack::exportTracker(QString dest) // default = ""
QFileDialog fileDialog(
this,
tr("Select file for exporting tracking pathes"),
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("");
bool autoCorrectOnlyExport = (mReco.getRecoMethod() == reco::RecognitionMethod::MultiColor) && // multicolor
mMultiColorMarkerWidget->autoCorrect->isChecked() &&
mMultiColorMarkerWidget->autoCorrectOnlyExport->isChecked();
{
#ifdef TIME_MEASUREMENT
double time1 = 0.0, tstart;