Skip to content
Snippets Groups Projects
Commit 28fc8d17 authored by am0ebe's avatar am0ebe
Browse files

save timestamp as ms (not ns), format time: only show h/m when dur long...

save timestamp as ms (not ns), format time: only show h/m when dur long enough, _rec->showProgress() to add to camInfo, solved nasty auto keyword segfault bug, make progressbar smaller [40 digits]
parent 16b69e31
Branches
No related tags found
No related merge requests found
...@@ -206,15 +206,11 @@ QString Cam::camInfo() ...@@ -206,15 +206,11 @@ QString Cam::camInfo()
{ {
QString camInfo = _name + DELIM + _ip + DELIM; QString camInfo = _name + DELIM + _ip + DELIM;
if( state() == Cam::disconnected ) if( state() == Cam::disconnected )
return camInfo + "disconnected"; return camInfo + "disconnected";
try try
{ {
// camInfo += name() + DELIM;
// camInfo += ip() + DELIM;
camInfo += id() + DELIM; camInfo += id() + DELIM;
std::string str; std::string str;
...@@ -229,7 +225,7 @@ QString Cam::camInfo() ...@@ -229,7 +225,7 @@ QString Cam::camInfo()
camInfo += stateToString(_state) + DELIM; camInfo += stateToString(_state) + DELIM;
if( _state == recording) if( _state == recording)
_rec->showProgress(); //xxx string to add to camInfo camInfo += _rec->getProgressBar() + DELIM;
else else
camInfo += "recdur: " + formatTime( _rec->dur().count() * 1000 ) + DELIM; camInfo += "recdur: " + formatTime( _rec->dur().count() * 1000 ) + DELIM;
......
...@@ -204,12 +204,9 @@ void Core::showInfo() ...@@ -204,12 +204,9 @@ void Core::showInfo()
{ {
print(QString("checkDirExists: %1").arg(cam()->rec()->checkDirExists())); print(QString("checkDirExists: %1").arg(cam()->rec()->checkDirExists()));
showRecordingStats(); showRecordingStats();
// cam()->rec()->showStats();
} }
//listCams
//showStats
//checkDiskSpace (show progressbar) //checkDiskSpace (show progressbar)
// calcDirSize, checkDirExists, //calcDirSize
} }
......
...@@ -47,6 +47,7 @@ void FrameProcessor::run() ...@@ -47,6 +47,7 @@ void FrameProcessor::run()
unsigned char* pdata = nullptr; unsigned char* pdata = nullptr;
_pframe->GetBuffer(pdata); _pframe->GetBuffer(pdata);
_pframe->GetTimestamp(_timestamp); _pframe->GetTimestamp(_timestamp);
_timestamp /= 1e6; //from ns to ms
_pframe->GetWidth(_width); _pframe->GetWidth(_width);
_pframe->GetHeight(_height); _pframe->GetHeight(_height);
_pframe->GetPixelFormat(_pixelFormat); _pframe->GetPixelFormat(_pixelFormat);
...@@ -63,23 +64,12 @@ void FrameProcessor::run() ...@@ -63,23 +64,12 @@ void FrameProcessor::run()
qWarning() << "⚠️ Could not write frame to file: " << filename; qWarning() << "⚠️ Could not write frame to file: " << filename;
// auto dur_ms = static_cast<int>(_timestamp - _prev_timestamp) / 1e6; //from ns to ms
// qDebug() << "rcvd Frame #" << _count << ": dur in ms" << dur_ms << ", timestamp: " << _timestamp;
// qDebug() << "rcvd Frame #" << _count << ": " << _width << "x" << _height << "px, format: " << _pixelFormatStr << ", timestamp: " << _timestamp << ", file: " << filename;
// #ifdef DEBUG
// QThread::msleep(2000); //simulate processing time // testing
// #endif
_width = 0; _width = 0;
_height = 0; _height = 0;
_timestamp = 0; _timestamp = 0;
_prev_timestamp = _timestamp;
emit frameProcessed(_pframe); emit frameProcessed(_pframe);
//need to reset pframe? // _pframe = FramePtr(nullptr); //need to reset pframe?
// _pframe = FramePtr(nullptr);
} }
...@@ -32,7 +32,6 @@ private: ...@@ -32,7 +32,6 @@ private:
VmbUint32_t _width; VmbUint32_t _width;
VmbUint32_t _height; VmbUint32_t _height;
VmbUint64_t _timestamp; VmbUint64_t _timestamp;
VmbUint64_t _prev_timestamp;
VmbPixelFormatType _pixelFormat; VmbPixelFormatType _pixelFormat;
}; };
...@@ -119,11 +119,13 @@ QString IPrinter::progressBar(QTimer* timer, int width) ...@@ -119,11 +119,13 @@ QString IPrinter::progressBar(QTimer* timer, int width)
int total_ms = timer->interval(); int total_ms = timer->interval();
int remaining_ms = timer->remainingTime(); int remaining_ms = timer->remainingTime();
auto elapsed_ms = total_ms - remaining_ms; auto elapsed_ms = total_ms - remaining_ms;
int progressInPercent = (double) elapsed_ms / total_ms; int progressInPercent = ((double) elapsed_ms / (double)total_ms) * 100;
//print in minutes and secs //print in minutes and secs
auto s1 = QString(QString::number(progressInPercent) + "% | " + formatTime(elapsed_ms) + " < " + formatTime(remaining_ms)); QString s1 = QString( formatTime(elapsed_ms) + " < " + formatTime(remaining_ms));
auto s2 = QString(progressBar(progressInPercent,width)); QString s2 = QString::number(progressInPercent) + "% " + progressBar(progressInPercent,width); // auto keyword leads to segfault here...
return s1 + s2; // qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << s2;
return s1 + " " + s2;
} }
QString IPrinter::progressBar(int percentage, int width) QString IPrinter::progressBar(int percentage, int width)
...@@ -155,5 +157,11 @@ QString IPrinter::formatTime(const int& milliseconds) ...@@ -155,5 +157,11 @@ QString IPrinter::formatTime(const int& milliseconds)
int hours = total_seconds / 3600; int hours = total_seconds / 3600;
int minutes = (total_seconds % 3600) / 60; int minutes = (total_seconds % 3600) / 60;
int seconds = total_seconds % 60; int seconds = total_seconds % 60;
return QString::asprintf("%02dh:%02dm:%02ds", hours, minutes, seconds);
if( hours == 0 && minutes == 0 )
return QString::asprintf("%02ds", seconds);
else if( hours == 0 )
return QString::asprintf("%02dm:%02ds", minutes, seconds);
else
return QString::asprintf("%02dh:%02dm:%02ds", hours, minutes, seconds);
} }
...@@ -40,8 +40,8 @@ public: ...@@ -40,8 +40,8 @@ public:
void print(const char*, const seconds&); void print(const char*, const seconds&);
QString progressBar(QTimer*, int width=0); QString progressBar(QTimer*, int width=40);
QString progressBar(int, int width=0); QString progressBar(int, int width=40);
protected: protected:
QString formatTime(const int&); QString formatTime(const int&);
......
#include "record.h" #include "record.h"
#include "opencv2/highgui.hpp"
#include "qjsonvalue.h" #include "qjsonvalue.h"
#include "utils.h" #include "utils.h"
#include "cam.h" #include "cam.h"
...@@ -27,7 +28,7 @@ _frames(FramePtrVector(utils::threadsPerCam())) ...@@ -27,7 +28,7 @@ _frames(FramePtrVector(utils::threadsPerCam()))
_updateTimer->setInterval(duration_cast<milliseconds>(updateInterval)); _updateTimer->setInterval(duration_cast<milliseconds>(updateInterval));
connect(_updateTimer, SIGNAL(timeout()), this, SLOT(showProgress())); connect(_updateTimer, SIGNAL(timeout()), this, SLOT(showProgressBar()));
} }
void Record::init(CamPtr cam) void Record::init(CamPtr cam)
...@@ -117,18 +118,9 @@ void Record::start() ...@@ -117,18 +118,9 @@ void Record::start()
void Record::stop() void Record::stop()
{ {
_updateTimer->stop(); _updateTimer->stop();
showProgressBar();
if(_timer->isActive()) if(_timer->isActive())
{ _timer->stop(); //user stop or error
//user stop or error
info( progressBar(_timer) );
_timer->stop();
}
else
{
//normal stop
info( progressBar(100) );
}
try try
{ {
...@@ -160,13 +152,11 @@ void Record::showStats() ...@@ -160,13 +152,11 @@ void Record::showStats()
info("get cam features:"); info("get cam features:");
_cam->printCamFeatures({ _cam->printCamFeatures({
"AcquisitionFrameRate", "AcquisitionFrameRate",
"AcquisitionFrameCount",
"DeviceTemperature",
"SensorWidth",
"SensorHeight",
"ExposureTime", "ExposureTime",
"Gain", "Gain",
"FileSize", "SensorWidth",
"SensorHeight",
"DeviceTemperature",
"PayloadSize", "PayloadSize",
"PixelFormat", "PixelFormat",
"PixelSize", "PixelSize",
...@@ -175,8 +165,8 @@ void Record::showStats() ...@@ -175,8 +165,8 @@ void Record::showStats()
info("-------------------------------"); info("-------------------------------");
info("get stream stats:"); info("get stream stats:");
_cam->printStreamFeatures({ _cam->printStreamFeatures({
"StatFrameRate",
"StatFrameDropped", "StatFrameDropped",
"StatLocalRate",
"StatFrameRescued", "StatFrameRescued",
"StatFrameShoved", "StatFrameShoved",
"StatFrameUnderrun", "StatFrameUnderrun",
...@@ -190,12 +180,14 @@ void Record::showStats() ...@@ -190,12 +180,14 @@ void Record::showStats()
}); });
} }
void Record::showProgress() void Record::showProgressBar()
{
info( progressBar(_timer) ); //
}
QString Record::getProgressBar()
{ {
//TODO test return progressBar(_timer);
//fps?
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
info( progressBar(_timer) );
} }
void Record::checkDiskSpace(const QString &dir, seconds dur) void Record::checkDiskSpace(const QString &dir, seconds dur)
......
...@@ -35,7 +35,8 @@ public: ...@@ -35,7 +35,8 @@ public:
public slots: public slots:
void stop(); void stop();
void showStats(); void showStats();
void showProgress(); void showProgressBar();
QString getProgressBar();
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment