-added a dely to DetectLoop after a positive motion detection to
 prevent motion event overlap.

-moved the 2 image diff pair compair to proper "end of array" in
 DetectLoop.

-increased the size of the image stream so queded up events will
 be able generate thumbnails properly.

-cleaned off a bunch of unused parameters in the code.

-adjusted the default motion sensitivity after real world
 testing.

-added libfuse-dev to setup.sh since imagemagic needs that to
 operate.
This commit is contained in:
Maurice ONeal 2023-05-27 09:33:14 -04:00
parent 4134d4befb
commit b445906403
5 changed files with 59 additions and 56 deletions

View File

@ -2,6 +2,6 @@
export DEBIAN_FRONTEND=noninteractive
apt update -y
apt install -y pkg-config cmake make g++
apt install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev x264 libx264-dev libilmbase-dev qt6-base-dev qtchooser qmake6 qt6-base-dev-tools libxkbcommon-dev
apt install -y ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev x264 libx264-dev libilmbase-dev qt6-base-dev qtchooser qmake6 qt6-base-dev-tools libxkbcommon-dev libfuse-dev
cp ./bin/magick /usr/bin/magick
chmod +x /usr/bin/magick

View File

@ -19,15 +19,12 @@ Camera::Camera(QObject *parent) : QObject(parent)
shared.camName.clear();
shared.retCode = 0;
shared.maxScore = 0;
shared.pixThresh = 50;
shared.imgThresh = 8000;
shared.imgThresh = 15000;
shared.maxEvents = 100;
shared.maxLogSize = 100000;
shared.skipCmd = false;
shared.postSecs = 60;
shared.evMaxSecs = 10;
shared.frameGap = 10;
shared.webRoot = "/var/www/html";
shared.webBg = "#485564";
shared.webTxt = "#dee5ee";
@ -41,6 +38,12 @@ int Camera::start(const QStringList &args)
if (rdConf(&shared))
{
QDir("live").removeRecursively();
QDir("img").removeRecursively();
QDir().mkdir("live");
QDir().mkdir("events");
QDir().mkdir("logs");
QDir().mkdir("img");
auto thr1 = new QThread(nullptr);
auto thr2 = new QThread(nullptr);
@ -68,14 +71,13 @@ Loop::Loop(shared_t *sharedRes, QThread *thr, QObject *parent) : QObject(parent)
loopTimer = 0;
connect(thr, &QThread::started, this, &Loop::init);
connect(this, &Loop::loopSig, this, &Loop::loopSlot);
moveToThread(thr);
}
void Loop::init()
{
loopTimer = new QTimer(nullptr);
loopTimer = new QTimer(this);
connect(loopTimer, &QTimer::timeout, this, &Loop::loopSlot);
@ -383,11 +385,14 @@ DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loo
{
pcTimer = 0;
heartBeat = 3;
delayCycles = 4; // this will be used to delay the
// actual start of DetectLoop by
// 12secs.
}
void DetectLoop::init()
{
pcTimer = new QTimer(nullptr);
pcTimer = new QTimer(this);
mod = false;
connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak);
@ -424,22 +429,31 @@ void DetectLoop::pcBreak()
bool DetectLoop::exec()
{
if (delayCycles > 0)
{
delayCycles -= 1;
}
else
{
auto curDT = QDateTime::currentDateTime();
auto images = backwardFacingFiles("img", ".bmp", curDT, 10);
if (images.size() < 3)
{
detLog("wrn: didn't pick up enough image files from the image stream. number of files: " + QString::number(images.size()), shared);
detLog(" will try again on the next loop.", shared);
}
else
{
QProcess extComp;
QStringList args;
auto pos = images.size() - 1;
args << "compare";
args << "-metric" << "FUZZ";
args << images[0];
args << images[1];
args << images[pos - 2];
args << images[pos - 1];
args << "/dev/null";
extComp.start("magick", args);
@ -458,11 +472,14 @@ bool DetectLoop::exec()
evt_t event;
event.timeStamp = curDT;
event.imgPath = images[2];
event.imgPath = images[pos];
delayCycles = shared->evMaxSecs / heartBeat;
shared->recList.append(event); mod = true;
}
}
}
return Loop::exec();
}

View File

@ -40,17 +40,12 @@ protected:
shared_t *shared;
QTimer *loopTimer;
bool interruptible;
int heartBeat;
protected slots:
virtual void init();
signals:
void loopSig();
private slots:
void loopSlot();
@ -124,6 +119,7 @@ class DetectLoop : public Loop
private:
QTimer *pcTimer;
int delayCycles;
bool mod;
void resetTimers();

View File

@ -184,9 +184,7 @@ bool rdConf(const QString &filePath, shared_t *share)
rdLine("max_event_secs = ", line, &share->evMaxSecs);
rdLine("post_secs = ", line, &share->postSecs);
rdLine("post_cmd = ", line, &share->postCmd);
rdLine("pix_thresh = ", line, &share->pixThresh);
rdLine("img_thresh = ", line, &share->imgThresh);
rdLine("frame_gap = ", line, &share->frameGap);
rdLine("max_events = ", line, &share->maxEvents);
rdLine("max_log_size = ", line, &share->maxLogSize);
}

View File

@ -28,7 +28,7 @@
using namespace std;
#define APP_VER "3.0.t6"
#define APP_VER "3.0.t7"
#define APP_NAME "Motion Watch"
#define APP_BIN "mow"
#define REC_LOG_NAME "rec_log_lines.html"
@ -36,7 +36,7 @@ using namespace std;
#define UPK_LOG_NAME "upk_log_lines.html"
#define DATETIME_FMT "yyyyMMddhhmmss"
#define STRFTIME_FMT "%Y%m%d%H%M%S"
#define MAX_IMAGES 40
#define MAX_IMAGES 1000
struct evt_t
{
@ -47,7 +47,6 @@ struct evt_t
struct shared_t
{
QList<evt_t> recList;
evt_t curEvent;
QString conf;
QString recLog;
QString detLog;
@ -61,19 +60,12 @@ struct shared_t
QString webFont;
QString webRoot;
bool skipCmd;
int frameGap;
int evMaxSecs;
int postSecs;
int maxScore;
int procCnt;
int hlsCnt;
int pixThresh;
int imgThresh;
int maxEvents;
int maxLogSize;
int retCode;
int postInd;
int evInd;
};
QString getParam(const QString &key, const QStringList &args);