Skip to content

Commit

Permalink
fix logging (proper frame timestamps, start time/date)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Mládek committed Aug 26, 2015
1 parent d4359cc commit 7e9f083
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions experiment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Experiment::~Experiment(){
void Experiment::start(){
timer.start();
elapsedTimer.start();
startTimestamp = QDateTime::currentMSecsSinceEpoch();
}

void Experiment::stop(){
Expand All @@ -62,9 +63,11 @@ void Experiment::stop(){
}

void Experiment::processFrame(){
capFrame capframe;

Mat frame;
capture >> frame;
capframe.timestamp = elapsedTimer.elapsed();

Detector::keyPoints points = detector->detect(&frame);

Expand All @@ -78,7 +81,6 @@ void Experiment::processFrame(){
distance = cv::norm(points.rat.pt - points.robot.pt);
}

capFrame capframe;
capframe.keypoints = points;
capframe.state = shockState;
capframe.currentLevel = currentLevel;
Expand Down Expand Up @@ -182,11 +184,15 @@ void Experiment::setShock(double mA){


QString Experiment::getLog(bool rat){
QDateTime start;
start.setMSecsSinceEpoch(startTimestamp);

QString log;
log += "%%BEGIN_HEADER\r\n";
log += " %%BEGIN DATABASE_INFORMATION\r\n";
log += " %Date.0 ( "+QDate::currentDate().toString("d.M.yyyy")+" )\r\n";
log += " %Time.0 ( "+QTime::currentTime().toString("h:mm")+" )\r\n";
log += " %Date.0 ( "+start.toString("d.M.yyyy")+" )\r\n";
log += " %Time.0 ( "+start.toString("h:mm")+" )\r\n";
log += " %MilliTime.0 ( "+QString::number(startTimestamp)+" )\r\n";
log += " %%END DATABASE_INFORMATION\r\n";
log += " %%BEGIN SETUP_INFORMATION\r\n";
log += " %TrackerVersion.0 ( Kachna Tracker v1.0 release 04/2014 )\r\n";
Expand Down Expand Up @@ -217,7 +223,7 @@ QString Experiment::getLog(bool rat){
for (unsigned i = 0;i < frames.size(); i++){
log += QString::number(i+1);
log += " ";
log += QString::number(i*40);
log += QString::number(frames[i].timestamp);
log += " ";
if (rat){
log += QString::number(frames[i].keypoints.rat.pt.x);
Expand Down
5 changes: 5 additions & 0 deletions experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ class Experiment : public QObject


private:
qint64 startTimestamp;
QString startTime;
QString startDate;

void setShock(double mA);

struct capFrame {
Detector::keyPoints keypoints;
int sectors;
int state;
int currentLevel;
qint64 timestamp;
};

VideoCapture capture;
Expand Down

0 comments on commit 7e9f083

Please sign in to comment.