#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; #define APP_VER "1.6.t4" #define APP_NAME "Motion Watch" #define TRIM_REMOVE " \n\r\t\f\v." struct shared_t { vector detThreads; vector conf; ofstream recLogFile; ofstream detLogFile; string recLogPath; string detLogPath; string recordUrl; string detectUrl; string outDir; string postCmd; string buffDir; string recSuffix; string detSuffix; string vidExt; string vidCodec; string camName; string webBg; string webTxt; string webFont; string webRoot; bool init; bool skipCmd; int cmdFinished; int clipLen; int frameGap; int pixThresh; int imgThresh; int numOfClips; int maxDays; int maxClips; int maxLogSize; int retCode; }; struct cmdRes_t { string cmd; pthread_t thr; int ret; bool finished; }; string leftTrim(const string &str, const string &toRemove); string rightTrim(const string &str, const string &toRemove); string trim(const string &str, const string &toRemove); string trim(const string &str); 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); bool createDir(const string &dir); bool createDirTree(const string &full_path); void enforceMaxDays(const string &dirPath, shared_t *share); void enforceMaxClips(const string &dirPath, shared_t *share); void rdLine(const string ¶m, const string &line, string *value); void rdLine(const string ¶m, const string &line, int *value); void statOut(shared_t *share); void waitForDetThreads(shared_t *share); bool rdConf(shared_t *share); vector parseForList(const string &arg, int argc, char** argv, bool argOnly = false, int count = 0); vector lsFilesInDir(const string &path, const string &ext = string()); vector lsDirsInDir(const string &path); #endif // COMMON_H