v1.5.t7
Moved logging out of it's own loop, hopefully this fixes the issue with it not outputting all log lines. recLoop() and detectLoop() will now update logs synchronously. The setup.sh script will now include gstreamer and pkg-config. This should help fix opencv video-io format support.
This commit is contained in:
parent
89129ad3f4
commit
651ec96083
3
setup.sh
3
setup.sh
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
apt update -y
|
apt update -y
|
||||||
apt install -y cmake g++ wget unzip git ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
|
apt install -y pkg-config
|
||||||
|
apt install -y cmake g++ wget unzip git ffmpeg gstreamer1.0* libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
|
||||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
apt update -y
|
apt update -y
|
||||||
apt install -y gcc-10 gcc-10-base gcc-10-doc g++-10
|
apt install -y gcc-10 gcc-10-base gcc-10-doc g++-10
|
||||||
|
|
|
@ -35,7 +35,7 @@ using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
|
|
||||||
#define APP_VER "1.5.t6"
|
#define APP_VER "1.5.t7"
|
||||||
#define APP_NAME "Motion Watch"
|
#define APP_NAME "Motion Watch"
|
||||||
|
|
||||||
struct shared_t
|
struct shared_t
|
||||||
|
|
|
@ -39,10 +39,15 @@ string combine(const vector<string> &log)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logLoop(shared_t *share)
|
void wrOutLogs(shared_t *share)
|
||||||
{
|
{
|
||||||
|
auto recLogFilePath = cleanDir(share->outDir) + "/recording_log.html";
|
||||||
|
auto detLogFilePath = cleanDir(share->outDir) + "/detection_log.html";
|
||||||
string htmlText = "<!DOCTYPE html>\n";
|
string htmlText = "<!DOCTYPE html>\n";
|
||||||
|
|
||||||
|
ofstream recFile(recLogFilePath.c_str());
|
||||||
|
ofstream detFile(detLogFilePath.c_str());
|
||||||
|
|
||||||
htmlText += "<html>\n";
|
htmlText += "<html>\n";
|
||||||
htmlText += "<head>\n";
|
htmlText += "<head>\n";
|
||||||
htmlText += "<link rel='stylesheet' href='/theme.css'>\n";
|
htmlText += "<link rel='stylesheet' href='/theme.css'>\n";
|
||||||
|
@ -50,23 +55,12 @@ void logLoop(shared_t *share)
|
||||||
htmlText += "<body>\n";
|
htmlText += "<body>\n";
|
||||||
htmlText += "<p>\n";
|
htmlText += "<p>\n";
|
||||||
|
|
||||||
while (share->logRun && (share->retCode == 0))
|
recFile << htmlText << combine(share->recLogLines) << "</p>\n</body>\n</html>\n";
|
||||||
{
|
detFile << htmlText << combine(share->detLogLines) << "</p>\n</body>\n</html>\n";
|
||||||
sleep(10);
|
|
||||||
|
|
||||||
enforceMaxLogLines(share->recLogLines, share);
|
|
||||||
enforceMaxLogLines(share->detLogLines, share);
|
|
||||||
|
|
||||||
auto recLogFilePath = cleanDir(share->outDir) + "/recording_log.html";
|
|
||||||
auto detLogFilePath = cleanDir(share->outDir) + "/detection_log.html";
|
|
||||||
|
|
||||||
ofstream recFile(recLogFilePath.c_str());
|
|
||||||
ofstream detFile(detLogFilePath.c_str());
|
|
||||||
|
|
||||||
recFile << htmlText << combine(share->recLogLines) << "</p>\n</body>\n</html>";
|
|
||||||
detFile << htmlText << combine(share->detLogLines) << "</p>\n</body>\n</html>";
|
|
||||||
|
|
||||||
recFile.close();
|
recFile.close();
|
||||||
detFile.close();
|
detFile.close();
|
||||||
}
|
|
||||||
|
enforceMaxLogLines(share->recLogLines, share);
|
||||||
|
enforceMaxLogLines(share->detLogLines, share);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
void recLog(const string &line, shared_t *share);
|
void recLog(const string &line, shared_t *share);
|
||||||
void detLog(const string &line, shared_t *share);
|
void detLog(const string &line, shared_t *share);
|
||||||
void logLoop(shared_t *share);
|
void wrOutLogs(shared_t *share);
|
||||||
void enforceMaxLogLines(vector<string> &log, shared_t *share);
|
void enforceMaxLogLines(vector<string> &log, shared_t *share);
|
||||||
string combine(const vector<string> &log);
|
string combine(const vector<string> &log);
|
||||||
|
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -16,6 +16,7 @@
|
||||||
void detectLoop(shared_t *share)
|
void detectLoop(shared_t *share)
|
||||||
{
|
{
|
||||||
detLog("detectLoop() -- start", share);
|
detLog("detectLoop() -- start", share);
|
||||||
|
wrOutLogs(share);
|
||||||
|
|
||||||
vector<string> bufFiles;
|
vector<string> bufFiles;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ void detectLoop(shared_t *share)
|
||||||
while (!bufFiles.empty() && !share->recLoopWait);
|
while (!bufFiles.empty() && !share->recLoopWait);
|
||||||
|
|
||||||
detLog("detectLoop() -- finished", share);
|
detLog("detectLoop() -- finished", share);
|
||||||
|
wrOutLogs(share);
|
||||||
}
|
}
|
||||||
|
|
||||||
void recLoop(shared_t *share)
|
void recLoop(shared_t *share)
|
||||||
|
@ -62,6 +64,7 @@ void recLoop(shared_t *share)
|
||||||
while (rdConf(share))
|
while (rdConf(share))
|
||||||
{
|
{
|
||||||
recLog("recLoop() -- start", share);
|
recLog("recLoop() -- start", share);
|
||||||
|
wrOutLogs(share);
|
||||||
|
|
||||||
if (!fileExists("/tmp/mow-lock"))
|
if (!fileExists("/tmp/mow-lock"))
|
||||||
{
|
{
|
||||||
|
@ -96,6 +99,8 @@ void recLoop(shared_t *share)
|
||||||
|
|
||||||
th2.join();
|
th2.join();
|
||||||
|
|
||||||
|
wrOutLogs(share);
|
||||||
|
|
||||||
if (!share->skipCmd)
|
if (!share->skipCmd)
|
||||||
{
|
{
|
||||||
recLog("motion not detected by detect loop.", share);
|
recLog("motion not detected by detect loop.", share);
|
||||||
|
@ -108,6 +113,7 @@ void recLoop(shared_t *share)
|
||||||
}
|
}
|
||||||
|
|
||||||
recLog("recLoop() -- finished", share);
|
recLog("recLoop() -- finished", share);
|
||||||
|
wrOutLogs(share);
|
||||||
}
|
}
|
||||||
|
|
||||||
share->logRun = false;
|
share->logRun = false;
|
||||||
|
@ -143,12 +149,8 @@ int main(int argc, char** argv)
|
||||||
sharedRes.init = true;
|
sharedRes.init = true;
|
||||||
sharedRes.logRun = true;
|
sharedRes.logRun = true;
|
||||||
|
|
||||||
thread th3(logLoop, &sharedRes);
|
|
||||||
|
|
||||||
recLoop(&sharedRes);
|
recLoop(&sharedRes);
|
||||||
|
|
||||||
th3.join();
|
|
||||||
|
|
||||||
return sharedRes.retCode;
|
return sharedRes.retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,9 +116,7 @@ bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
detLog("failed to open buff file: " + buffFile + " for reading.", share);
|
detLog("failed to open buff file: " + buffFile + " for reading. check permissions and/or opencv's video-io support (gstreamer/ffmpeg).", share);
|
||||||
detLog("check formatting/permissions.", share);
|
|
||||||
detLog("also check if opencv was compiled with FFMPEG encoding enabled.", share);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user