Added a -v command line option to display the application's current version. The application version is now defined in a single a const value called APP_VER so bumping the version number now means updating this single value in common.h. Versioning scheme will now be major.minor.[test_rev]. test_rev will be t1, 2, 3, etc... as updates are pushed to the test branch. all code pushes to master shall bump major or minor and then remove test_rev. Removed the detect loop's motion latching affect so it ONLY calls wrOut if the video clip contains motion. Fixed a bug in the recording loop that fail to create the needed sub-dir before calling FFMPEG.
82 lines
2.5 KiB
C++
82 lines
2.5 KiB
C++
#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 <iostream>
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <unistd.h>
|
|
#include <time.h>
|
|
#include <stdlib.h>
|
|
#include <sys/stat.h>
|
|
#include <errno.h>
|
|
#include <vector>
|
|
#include <thread>
|
|
#include <dirent.h>
|
|
#include <filesystem>
|
|
|
|
#include <opencv4/opencv2/opencv.hpp>
|
|
#include <opencv4/opencv2/videoio.hpp>
|
|
|
|
using namespace cv;
|
|
using namespace std;
|
|
using namespace std::filesystem;
|
|
|
|
#define BUF_SZ 10
|
|
#define APP_VER "1.3.t2"
|
|
|
|
struct shared_t
|
|
{
|
|
string recordUrl;
|
|
string outDir;
|
|
string postCmd;
|
|
string conf;
|
|
string buffDir;
|
|
string concatTxtTmp;
|
|
string concatShTmp;
|
|
string createShTmp;
|
|
string vidExt;
|
|
bool init;
|
|
bool recLoopWait;
|
|
bool skipCmd;
|
|
int tmpId;
|
|
int colorThresh;
|
|
int secs;
|
|
int blockThresh;
|
|
int blockX;
|
|
int blockY;
|
|
int maxDays;
|
|
int retCode;
|
|
};
|
|
|
|
string genTmpFile(const string &dirOut, const string &ext, shared_t *share);
|
|
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);
|
|
bool fileExists(const string& name);
|
|
void wrOut(const string &buffFile, shared_t *share);
|
|
void replaceAll(string &str, const string &from, const string &to);
|
|
void enforceMaxDays(shared_t *share);
|
|
void rdLine(const string ¶m, const string &line, string *value);
|
|
void rdLine(const string ¶m, const string &line, int *value);
|
|
bool rdConf(shared_t *share);
|
|
bool capPair(Mat &prev, Mat &next, VideoCapture &capture, shared_t *share);
|
|
Mat toGray(const Mat &src);
|
|
vector<string> lsFilesInDir(const string &path, const string &ext);
|
|
|
|
#endif // COMMON_H
|