diff --git a/src/camera.cpp b/src/camera.cpp index e7797f6..d768f53 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -267,54 +267,63 @@ bool Upkeep::exec() EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(sharedRes, thr, parent) { heartBeat = 2; + highScore = 0; + cycles = 0; } bool EventLoop::exec() -{ - QStringList vidList; - QString imgPath; - QString name; - float highScore = 0; - - while (!shared->recList.isEmpty()) +{ + if (cycles * 2 >= shared->evMaxSecs) { - auto event = shared->recList[0]; - auto maxFiles = shared->evMaxSecs / 2; - // there's 2 secs in each hls segment + vidList.removeDuplicates(); - if (highScore < event.score) + if (!vidList.size() > 1) { - name = event.timeStamp.toString(DATETIME_FMT); - imgPath = event.imgPath; - highScore = event.score; + recLog("attempting write out of event: " + name, shared); + + if (wrOutVod(name, vidList)) + { + genHTMLvod(name); + + QProcess proc; + QStringList args; + + args << "convert"; + args << imgPath; + args << "events/" + name + ".jpg"; + + proc.start("magick", args); + proc.waitForFinished(); + } } - vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); - vidList.removeLast(); - vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); + cycles = 0; + highScore = 0; - shared->recList.removeFirst(); + vidList.clear(); } - - vidList.removeDuplicates(); - - if (!vidList.size() > 1) + else { - recLog("attempting write out of event: " + name, shared); + cycles += 1; - if (wrOutVod(name, vidList)) + while (!shared->recList.isEmpty()) { - genHTMLvod(name); + auto event = shared->recList[0]; + auto maxFiles = shared->evMaxSecs / 2; + // there's 2 secs in each hls segment - QProcess proc; - QStringList args; + if (highScore < event.score) + { + name = event.timeStamp.toString(DATETIME_FMT); + imgPath = event.imgPath; + highScore = event.score; + } - args << "convert"; - args << imgPath; - args << "events/" + name + ".jpg"; + vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); + vidList.removeLast(); + vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); - proc.start("magick", args); - proc.waitForFinished(); + shared->recList.removeFirst(); } } @@ -485,8 +494,6 @@ bool DetectLoop::exec() event.score = score; event.imgPath = images[pos]; - delayCycles = (shared->evMaxSecs / 2) - 1; - shared->recList.append(event); mod = true; } } diff --git a/src/camera.h b/src/camera.h index afe256b..679e103 100644 --- a/src/camera.h +++ b/src/camera.h @@ -101,6 +101,12 @@ class EventLoop : public Loop private: + QStringList vidList; + QString imgPath; + QString name; + float highScore; + uint cycles; + bool wrOutVod(const QString &name, const QStringList &vids); public: diff --git a/src/common.h b/src/common.h index 4520114..993ac88 100644 --- a/src/common.h +++ b/src/common.h @@ -28,7 +28,7 @@ using namespace std; -#define APP_VER "3.0.t14" +#define APP_VER "3.0.t15" #define APP_NAME "Motion Watch" #define APP_BIN "mow" #define REC_LOG_NAME "rec_log_lines.html"