#ifndef COMMON_H #define COMMON_H // This file is part of Motion Watch. // Motion Watch is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Motion Watch is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace cv; using namespace std; using namespace std::filesystem; using namespace std::chrono; #define APP_VER "2.0.t5" #define APP_NAME "Motion Watch" #define REC_LOG_NAME "rec_log_lines.html" #define DET_LOG_NAME "det_log_lines.html" #define UPK_LOG_NAME "upk_log_lines.html" struct pls_t { string fileName; string clipPath; string dstPath; string extINF; uint64_t createTime; Mat thumbnail; }; struct shared_t { vector recList; string conf; string recLog; string detLog; string upkLog; string recordUrl; string outDir; string postCmd; string camName; string webBg; string webTxt; string webFont; string webRoot; bool skipCmd; bool postCmdRunning; int schSec; int frameGap; int pixThresh; int imgThresh; int maxDays; int maxEvents; int maxLogSize; int retCode; }; string genVidNameFromLive(const string &tsPath); string genEventPath(const string &tsPath); string genDstFile(const string &dirOut, const char *fmt, const string &ext); string genTimeStr(const char *fmt); string cleanDir(const string &path); string parseForParam(const string &arg, int argc, char** argv, bool argOnly, int &offs); string parseForParam(const string &arg, int argc, char** argv, bool argOnly); bool createDir(const string &dir); bool createDirTree(const string &full_path); void rdLine(const string ¶m, const string &line, string *value); void rdLine(const string ¶m, const string &line, int *value); void cleanupEmptyDirs(const string &path); void cleanupStream(const string &plsPath); void enforceMaxEvents(shared_t *share); bool rdConf(shared_t *share); vector lsFilesInDir(const string &path, const string &ext = string()); vector lsDirsInDir(const string &path); uint64_t genEpoch(); #endif // COMMON_H